%Warning: This was Latex'ed on a Mac in order to include the figures
% this next is to generate figures on the Mac
\def\picture #1 by #2 (#3){
  $${\vbox to #2{
    \hrule width #1 height 0pt depth 0pt
    \vfill
    \special{picture #3} % this is the low-level interface
    }}$$
  }

\input  /zu/6001-devel/6001mac
%\input 6001mac

\begin{document}

\psetheader{Fall Semester, 1993}{Problem Set 4}

\medskip

\begin{flushleft}
Issued:  Tuesday, September 28 \\
\smallskip
Tutorial preparation for: Week of October 4\\
\smallskip
Written solutions due: Friday, October 8 in Recitation \\
\smallskip
Reading:
\begin{tightlist}
\item Course notes: finish section 2.2
\item code files {\tt hend.scm} and {\tt hutils.scm} (attached to this handout)
\end{tightlist}
\end{flushleft}

\begin{center}
{\bf A Graphics Design Language}
\end{center}

In this assignment, you will work with the Peter Henderson's
``square-limit'' graphics design language, which Hal described in
lecture on September 28.  Before beginning work on this programming
assignment, you should review the notes for that lecture.  The goal of
this problem set is to reinforce ideas about data abstraction and
higher-order procedures, and to emphasize the expressive power that
derives from appropriate primitives, means of combination, and means
of abstraction.\footnote{This problem set was developed by Hal
Abelson, based upon work by Peter Henderson (``Functional Geometry,''
in {\em Proc. ACM Conference on Lisp and Functional Programming},
1982).  The image display code was designed and implemented by Daniel
Coore.}

\begin{figure}[b]
\picture 3.90 in by 1.81 in (escher)
\caption{{\protect\footnotesize
A picture of M.C. Escher, and the same picture transformed by the
square-limit process.}}
\label{escher}
\end{figure}

Section 1 of this handout reviews the language, as presented in
lecture.  You will need to study this in order to prepare the
tutorial presentations in section 2.  Section 3 gives the lab assignment,
which includes an optional design contest.

\section{1. The Square-limit language}

Remember from lecture that the key idea in the square-limit language
is to use {\em painter} procedures that take frames as inputs and
paint images that are scaled to fit the frames.

\subsection{Basic data structures}

Vectors are represented as pairs of numbers.

\beginlisp
(define make-vect cons)
(define vector-xcor car)
(define vector-ycor cdr)
\endlisp

Here are the operations of vector addition, subtraction, and scaling a
vector by a number:

\beginlisp
(define (vector-add v1 v2)
  (make-vect (+ (xcor v1) (xcor v2))
             (+ (ycor v1) (ycor v2))))
\null
(define (vector-sub v1 v2)
  (vector-add v1 (vector-scale -1 v2)))
\null
(define (vector-scale x v)
  (make-vect (* x (xcor v))
             (* x (ycor v))))
\endlisp

A pair of vectors determines a directed line segment---the segment
running from the endpoint of the first vector to the endpoint of the
second vector:

\beginlisp
(define make-segment cons)
(define segment-start car)
(define segment-end cdr)
\endlisp

\subsubsection{Frames}

A frame is represented by three vectors: an origin and two edge
vectors.

\beginlisp
(define (make-frame origin edge1 edge2)
  (list 'frame origin edge1 edge2))
\null
(define frame-origin cadr)
(define frame-edge1 caddr)
(define frame-edge2 cadddr)
\endlisp

The frame's origin is given as a vector with respect to the origin of
the graphics-window coordinate system.  The edge vectors specify the
offsets of the corners of the frame from the origin of the frame.  If
the edges are perpendicular, the frame will be a rectangle; otherwise
it will be a more general parallelogram.  Figure~\ref{frames} shows a
frame and its associated vectors.

\begin{figure}
\picture 3.51 in by 2.42 in (frame)
\caption{{\protect\footnotesize A frame is represented by an origin
and two edge vectors.}}
\label{frames}
\end{figure}

Each frame determines a system of ``frame coordinates'' $(x,y)$ where
$(0,0)$ is the origin of the frame, $x$ represents the displacement
along the first edge (as a fraction of the length of the edge) and $y$ is the
displacement along the second edge.  For example, the origin of the
frame has frame coordinates $(0,0)$ and the vertex diagonally opposite
the origin has frame coordinates $(1,1)$.

Another way to express this idea is to say that each frame has an
associated {\em frame coordinate map} that transforms the frame
coordinates of a point into the Cartesian plane coordinates of the
point.  That is, $(x,y)$ gets mapped onto the Cartesian
coordinates of the point given by the vector sum
\begin{displaymath}
\hbox{\rm Origin(Frame)} + x\cdot \hbox{\rm Edge}_1\hbox{\rm (Frame)}
+ y\cdot \hbox{\rm Edge}_2\hbox{\rm (Frame)}
\end{displaymath}

We can represent the frame coordinate map by the following procedure:\\
\beginlisp
(define (frame-coord-map frame)
  (lambda (point-in-frame-coords)
    (vector-add
     (frame-origin frame)
     (vector-add (vector-scale (vector-xcor point-in-frame-coords)
                               (frame-edge1 frame))
                 (vector-scale (vector-ycor point-in-frame-coords)
                               (frame-edge2 frame))))))
\endlisp

For example, {\tt ((frame-coord-map a-frame) (make-vect 0 0))} will
return the same value as {\tt (frame-origin a-frame)}.

The procedure {\tt make-relative-frame} provides a convenient way to
transform frames.  Given a frame and three points {\tt origin}, {\tt
corner1}, and {\tt corner2} (expressed in frame coordinates), it
returns a new frame with those corners:

\beginlisp
(define (make-relative-frame origin corner1 corner2)
  (lambda (frame)
    (let ((m (frame-coord-map frame)))
      (let ((new-origin (m origin)))
        (make-frame new-origin
                    (vector-sub (m corner1) new-origin)
                    (vector-sub (m corner2) new-origin))))))
\endlisp

\noindent
For example,\\
\beginlisp
(make-frame-relative (make-vect .5 .5) (make-vect 1 .5) (make-vect .5 1))
\endlisp

\noindent
returns the procedure that transforms a frame into the upper-right
quarter of the frame.

\subsubsection{Painters}

As described in lecture, a painter is a procedure that, given a frame
as argument, ``paints'' a picture in the frame.  That is to say, if
{\tt p} is a painter and {\tt f} is a frame, then evaluating {\tt (p
f)} will cause an image to appear in the frame.  The image will be
scaled and stretched to fit the frame.

The language you will be working with includes four ways to create
primitive painters.

The simplest painters are created with {\tt number->painter}, which
takes a number as argument.  These painters fill a frame with a solid
shade of gray.  The number specifies a gray level: 0 is black, 255 is
white, and numbers in between are increasingly lighter shades of
gray.  Here are some examples:

\beginlisp
(define black (number->painter 0))
(define white (number->painter 255))
(define gray (number->painter 150))
\endlisp

\noindent
You can also specify a painter using {\tt procedure->painter}, which
takes a procedure as argument.  The procedure determines a gray level
(0 to 255) as a function of $(x,y)$ position, for example:

\beginlisp
(define diagonal-shading
  (procedure->painter (lambda (x y) (* 100 (+ x y)))))
\endlisp

\noindent
The $x$ and $y$ coordinates run from 0 to 1 and specify the fraction
that each point is offset from the frame's origin along the frame's
edges.  (See figure~\ref{frames}.) Thus, the frame is filled out by
the set of points $(x,y)$ such that $0\leq x,y \leq 1$.

A third kind of painter is created by {\tt segments->painter}, which
takes a list of line segments as argument.  This paints the line
drawing specified by the list segments.  The $(x,y)$ coordinates of
the line segments are specified as above.  For example, you can make
the ``Z'' shape shown in figure~\ref{primitive-painters} as

\beginlisp
(define mark-of-zorro
  (let ((v1 (make-vect .1 .9))
        (v2 (make-vect .8 .9))
        (v3 (make-vect .1 .2))
        (v4 (make-vect .9 .3)))
    (segments->painter
     (list (make-segment v1 v2)
           (make-segment v2 v3)
           (make-segment v3 v4)))))
\endlisp

The final way to create a primitive painter is from a stored image.
The procedure {\tt load-painter} uses an image from the 6001 image
collection to create a painter.\footnote{The images are kept in the
directory {\tt 6001-images}.  Use the Edwin command
{\tt M-x list-directory} to see entire contents of the directory.
Each image is $128\times 128$, stored in ``pgm'' format.}
or instance:

\beginlisp
(define fovnder (load-painter "fovnder"))
\endlisp

\noindent
will paint an image of William Barton Rogers, the {\sc fovnder} of MIT.
(See figure~\ref{primitive-painters}.)

\begin{figure}
\picture 3.89 in by 1.82 in (primpics)
\caption{{\protect\footnotesize
Examples of primitive painters: {\tt mark-of-zorro} and {\tt fovnder}.}}
\label{primitive-painters}
\end{figure}

\subsection{Transforming and combining painters}

We can transform a painter to produce a new painter which, when
given a frame, calls the original painter on the transformed frame.
For example, if {\tt p} is a painter and {\tt f} is a frame, then\\
\beginlisp
(p ((make-frame-relative (make-vect .5 .5) (make-vect 1 .5) (make-vect .5 1))
    f))
\endlisp

\noindent
will paint in the upper-right-hand corner of the frame.

We can abstract this idea with the following procedure:

\beginlisp
(define (transform-painter origin corner1 corner2)
  (lambda (painter)
    (compose painter
             (make-relative-frame origin corner1 corner2))))
\endlisp

\noindent
Calling this with an origin and two corners, returns a procedure that
transforms a painter into one that paints relative to a new frame with
the specified origin and corners.  For example, we could define:\\
\beginlisp
(define (shrink-to-upper-left painter)
  ((transform-painter (make-vect .5 .5) (make-vect 1 .5) (make-vect .5 1))
   painter))
\endlisp

\noindent
Note that this can be written equivalently as\\
\beginlisp
(define shrink-to-upper-left
  (transform-painter (make-vect .5 .5) (make-vect 1 .5) (make-vect .5 1)))
\endlisp

Other transformed frames will flip images horizontally:\\
\beginlisp
(define flip-horiz
  (transform-painter (make-vect 1 0)
                     (make-vect 0 0)
                     (make-vect 1 1)))
\endlisp

\noindent
or rotate images counterclockwise by 90 degrees:\\
\beginlisp
(define rotate90
  (transform-painter (make-vect 1 0)
                     (make-vect 1 1)
                     (make-vect 0 0)))
\endlisp

By repeating rotations, we can create painters whose images are
rotated through 180 or 270 degrees:

\beginlisp
(define rotate180 (repeated rotate90 2))
(define rotate270 (repeated rotate90 3))
\endlisp

We can combine the results of two painters a single frame by
calling each painter on the frame:

\beginlisp
(define (superpose painter1 painter2)
  (lambda (frame)
    (painter1 frame)
    (painter2 frame)))
\endlisp

To draw one image beside another, we combine one in the left half
of the frame with one in the right half of the frame:

\beginlisp
(define (beside painter1 painter2)
  (let ((split-point (make-vect .5 0)))
    (superpose
     ((transform-painter zero-vector
                         split-point
                         (make-vect 0 1))
      painter1)
     ((transform-painter split-point
                         (make-vect 1 0)
                         (make-vect .5 1))
      painter2))))

\endlisp

We can also define painters that combine painters vertically, by
using {\tt rotate} together with {\tt beside}.  The painter produced
by {\tt below} shows the image for {\tt painter1} below the image
for {\tt painter2}:

\beginlisp
(define (below painter1 painter2)
  (rotate270 (beside (rotate90 painter2)
                     (rotate90 painter1))))
\endlisp

\section{2. Tutorial exercises}

You should prepare the following exercises for oral presentation in
tutorial.  They cover material in sections 2.1 and 2.2 of the text,
and they also test your understanding of the square-limit language
described above, in preparation for doing the lab in section 1 of
this handout.  You may wish to use the computer to check your answers
to these questions, but you should try to do them (at least
initially) without the computer.

\paragraph{Tutorial exercise 1:}
Show how to define a procedure {\tt butlast} that, given a list,
returns a new list containing all but the last element of the original
list.  For example

\beginlisp
(butlast '(1 2 3 4 5 6))
;Value: (1 2 3 4 5)
\endlisp

\paragraph{Tutorial exercise 2:}
In the square-limit language, a frame is represented as a list of four
things---the symbol {\tt frame} followed by the origin and the two
edge vectors.

\begin{enumerate}

\item Pick some values for the coordinates of origin and edge vectors
and draw the box-and-pointer structure for the resulting frame.

\item Suppose we change the representation of frames and represent
them instead as a list of three vectors---the origin and the two
edges---without including the symbol {\tt frame}.  Give the new
definitions of {\tt make-frame}, {\tt frame-origin}, {\tt
frame-edge1}, and {\tt frame-edge2} for this representation.  In
addition to changing these constructors and selectors, what other
changes to the implementation of the square-limit language are
required in order to use this new representation?

\item Why might it be useful to include the symbol {\tt frame} as part
of the representation of frames?
\end{enumerate}

\paragraph{Tutorial exercise 3:}
Describe the patterns drawn by

\beginlisp
(procedure->painter (lambda (x y) (* x y)))
(procedure->painter (lambda (x y) (* 255 x y)))
\endlisp

\paragraph{Tutorial exercise 4:}
Captain Abstraction is insulted that the Mark of Zorro appears in this
problem set, while his mark does not.  Show how to use {\tt
segments->painter} to draw an ``A'' for Captain Abstraction.  Don't
worry about getting the coordinates exactly correct---just get the
general shape right.

\paragraph{Tutorial exercise 5:}
Section 1 defines {\tt below} in terms of {\tt beside} and {\tt
rotate}.  Give an alternative definition of {\tt below} that does not
use {\tt beside}.

\paragraph{Tutorial exercise 6:}
Define the painter transformation {\tt flip-vertically}.

\paragraph{Tutorial exercise 7:}
Describe the effect of

\beginlisp
(transform-painter (make-vect .1 .9)
                   (make-vect 1.5 1)
                   (make-vect .2 0))
\endlisp

\section{3. To do in lab}

Load the code for problem set 4, which contains the procedures
described in section 1.  You will not need to modify any of these.  We
suggest that you define your new procedures in a separate (initially
empty) editor buffer, to make it easy to reload the system if things
get fouled up.

When the problem set code is loaded, it will create three graphics windows,
named {\tt g1}, {\tt g2}, and {\tt g3}.  To paint a picture in a
window, use the procedure {\tt paint}.  For example,

\beginlisp
(paint g1 fovnder)
\endlisp

\noindent
will show a picture of William Barton Rogers in window {\tt g1}.
There is also a procedure called {\tt paint-hi-res}, which paints the
images at higher resolution ($256 \times 256$ rather than $128 \times
128$).  Painting at a higher resolution produces better looking
images, but takes four times as long.  As you work on this problem
set, you should look at the images using {\tt paint}, and reserve {\tt
paint-hi-res} to see the details of images that you find
interesting.\footnote{Painting a primitive image like {\tt fovnder} won't
look any different at high resolution, because the original picture is
only $128 \times 128$.  But as you start stretching and shrinking the
image, you will see differences at higher resolution.}

\paragraph{Printing pictures} You can print images on the laserjet
printer with Edwin's {\tt M-x print-graphics} command as described
in the {\em Don't Panic} manual.  The laserjet cannot print true
greyscale pictures, so the pictures will not look as good as they do
on the screen. Please print only a few images---only the ones that you
really want---so as not to waste paper and clog the printer queues.
We suggest that you print only images created with {\tt paint-hi-res},
not {\tt paint}.

\paragraph{Lab exercise 1:}
Make a collection of primitive painters to use in the rest of this
lab.  In addition to the ones predefined for you (and listed in
section 1), define at least one new painter of each of the four
primitive types: a uniform grey level made with {\tt number->painter},
something defined with {\tt procedure->painter}, a line-drawing made
with {\tt segments->painter}, and an image of your choice that is
loaded from the 6001 image collection with {\tt load-painter}.  Turn
in a list of your definitions.

\paragraph{Lab exercise 2:}
Experiment with some combinations of your primitive painters, using
{\tt beside}, {\tt below}, {\tt superpose}, flips, and rotations, to get a
feel for how these means of combination work.  You needn't turn in
anything for this exercise.

\paragraph{Lab exercise 3}
The ``diamond'' of a frame is defined to be the smaller frame
created by joining the midpoints of the original frame's sides, as shown in
figure~\ref{diamond}a.  Define a procedure {\tt
diamond} that transforms a painter into one that paints its image in
the diamond of the specified frame, as shown in
figure~\ref{diamond}b.  Try some examples, and turn in a listing of
your procedure.

\begin{figure}
\picture 3.72 in by 1.82 in (diamond)
\caption{{\protect\footnotesize
(a) The ``diamond of a frame is formed by joining the midpoints
of the sides.  (b) Painting created by {\tt (diamond fovnder)}.}}
\label{diamond}
\end{figure}

\paragraph{Lab exercise 4}

The ``diamond'' transformation has the property that, if you start
with a square frame, the diamond frame is still square
(although rotated).  Define a transformation similar to {\tt
diamond}, but which does not produce square frames.  Try your
transformation on some images to get some nice effects.  Turn in a
listing of your procedure.

\paragraph{Lab exercise 5}
The following recursive {\tt right-split} procedure was demonstrated
in lecture:

\beginlisp
(define (right-split painter n)
  (if (= n 0)
      painter
      (let ((smaller (right-split painter (- n 1))))
        (beside painter (below smaller smaller)))))
\endlisp

Try this with some of the painters you've previously defined, both
primitives and combined ones.  Now define an analogous {\tt up-split}
procedure as shown in figure~\ref{up-split}.  Make sure to test it on
a variety of painters.  Turn in a listing of your procedure.  (In
defining your procedure, remember that {\tt (below painter1
painter2)} produces {\tt painter1} below {\tt painter2}.)

\begin{figure}
\picture 3.75 in by 1.79 in (up-split)
\beginlisp
                  (up-split mark-of-zorro 4)      (up-split fovnder 4)
\endlisp
\caption{{\protect\footnotesize
The {\tt up-split} procedure places a picture below two (recursively)
up-split copies of itself.}}
\label{up-split}
\end{figure}

\paragraph{Lab exercise 6}
{\tt Right-split} and {\tt up-split} are both examples of a common
pattern that begins with a means of combining two painters and applies
this over and over in a recursive pattern.  We can capture this idea
in a procedure called {\tt keep-combining}, which takes as argument a
{\tt combiner} (which combines two painters).  For instance, we should
be able to give an alternative definition of {\tt right-split} as

\beginlisp
(define new-right-split
  (keep-combining
   (lambda (p1 p2)
     (beside p1 (below p2 p2)))))
\endlisp

\noindent
Complete the following definition of {\tt keep-combining}:

\beginlisp
(define (keep-combining combine-2)
  ;; combine-2 = (lambda (painter1 painter2) ...)
  (lambda (painter n)
    ((repeated
      {\rm $\langle$ fill in missing expression $\rangle$}
      n)
     painter)))
\endlisp

\noindent
Show that you can indeed define {\tt right-split} using your
procedure, and give an analogous definition of {\tt up-split}.

\paragraph{Lab exercise 7}
Once you have {\tt keep-combining}, you can use it to define lots of
recursive means of combination.  Figure~\ref{keep-combining} shows
three examples.  Invent some variations of your own.  Turn in the code
and one or two sample pictures.

\begin{figure}
\picture 1.81 in by 1.81 in (nest-fovnder)

\beginlisp
                     (define nest-diamonds
                       (keep-combining
                        (lambda (p1 p2) (superpose p1 (diamond p2)))))
\null
                     (nest-diamonds fovnder 4)
\endlisp

\picture 4.42 in by 1.81 in (combine)
\beginlisp
     (define new-comb                              (define mix-with-fovnder
       (keep-combining                               (keep-combining
        (lambda (p1 p2)                               (lambda (p1 p2)
          (square-limit (below p1 p2) 2))))             (below (beside p1
                                                                       fovnder)
                                                               (beside p2 p2)))))
\null
     (new-comb mark-of-zorro 2)                     (mix-with-fovnder romana 3)
\endlisp
\caption{{\protect\footnotesize
Some recursive combination schemes, defined with {\tt keep-combining}.}}
\label{keep-combining}
\end{figure}

\paragraph{Lab exercise 8}
Define the {\tt square-limit} transformation illustrated in
figure~\ref{escher}.  The recursive plan for this transformation was
described in lecture.  Using {\tt right-split} and {\tt up-split},
define a {\tt corner-split} transformation that returns a painter
that will generate one-fourth of the desired image.  Then apply a
transformation {\tt 4times} to the {\tt corner-split} painter.  {\tt
4times} returns a painter that paints its image (suitably rotated) in
each quarter of its argument frame.  Turn in a listing of the
procedures you define: {\tt corner-split}, {\tt 4times}, and any
others.  Also turn in a clear explanation (a few sentences together
with a diagram) of the recursive plan for {\tt corner-split}.

\paragraph{Lab exercise 9}
The procedures you have implemented give you a wide choice of things
to experiment with.  Invent some new means of combination, both simple
ones like {\tt beside} and complex higher-order ones like {\tt
keep-combining} and see what kinds of interesting images you can create.
Turn in the code and one or two figures.

\paragraph{Contest (Optional)}

Hopefully, you generated some interesting designs in doing this
assignment.  If you wish, you can enter printouts of your best designs
in the 6.001 PS4 design contest.  Turn in your design collection
together with your homework, but {\em stapled separately}, and make
sure your name is on the work.  For each design, show the expression
you used to generate it.  Designs will be judged by the 6.001 staff and
other paragons of design expertise, and fabulous prizes will be
awarded in lecture.  There is a limit of five entries per student.
Make sure to turn in not only the pictures, but also the procedure(s) that
generated them.

\end{document}


\section{CP Algorithms}

\begin{myitemize}
\item \href{cp-algorithms.com/}{CP Algorithms}
\end{myitemize}

\subsection{Cycle Finding Algorithms}

\algorithm{}{Floyd's cycle-finding algorithm}{
    This algorithm finds a cycle by using two pointer. These pointers move over the sequence at different speeds. \textbf{In each iteration the first pointer advances to the next element, but the second pointer advances two elements.} It's not hard to see, that if there exists a cycle, the second pointer will make at least one full cycle and then meet the first pointer during the next few cycle loops. \emph{If the cycle length is $\lambda$ and the $\mu$ is the first index at which the cycle starts, then the algorithm will run in $ O(\lambda+\mu) $ time.}

    This algorithm is also known as \textbf{tortoise and the hare algorithm}, based on the tale in which a tortoise (here a slow pointer) and a hare (here a faster pointer) make a race.

    It is actually possible to determine the parameter $\lambda$
and $\mu$ using this algorithm (also in $ O(\lambda+\mu) $ time and $ O(1) $ space), but here is just the simplified version for finding the cycle at all. The algorithm and returns true as soon as it detects a cycle.}

\begin{lstlisting}[language=python]
def floyd(f, x0, n):
    tortoise = x0
    hare = x0
    while(tortoise != hare):
        tortoise = f(tortoise, n)
        hare = f(hare, n)
        hare = f(hare, n)
    return True
\end{lstlisting}

\vspace{2em}

\algorithm{}{Brent's algorithm}{Brent uses a similar algorithm as Floyd. It also uses two pointer. But instead of advancing the pointers by one and two respectably, we advance them in powers of two. As soon as $ 2^i  $is greater than $\lambda$ and $\mu$, we will find the cycle.}

\begin{lstlisting}[language=python]
def f(x, n):
    return (x*x + 3)%n

def brent(f, x0, n):
    tortoise = x0
    hare = f(x0, n)
    l = 1
    while(tortoise != hare):
        tortoise = f(tortoise, n)
        for i in range(l):
            hare = f(hare, n)
            if(hare == tortoise):
                return True
        l *= 2
    return True
\end{lstlisting}


%%==========================
%% Section 2.0: Introduction
%%==========================
\documentclass[../dissertation.tex]{subfiles}

\begin{document}
% \setcounter{section}{-1}
\section{Introduction}\label{sec2:Intro}

One of the consequences of \eqref{eq1:PoleColapseResidue} along with
\eqref{eq0:GFs} is that $G_\star^+(x; \lambda)$ ($\star = L \text{, or } R$)
grows linearly as a function of $x \in \mathbb R$ when $\lambda = 0$. This fact
aligns with intuition, since the two simple poles $\xi = 0$ and $\xi=\lambda$
of $1/p$ coalesce into a single double pole as $\lambda \to 0$.
Since $r$ is a function of $\lambda$, in order to prove the direct scattering
map $\mathscr D: u \mapsto r$ is well-defined and Lipschitz continuous, we
need estimates on the solutions to the integral equations
\eqref{eq0:JostIE}\textemdash{}and hence estimates on the Green's
functions\textemdash{}which are uniform in $\lambda$. This will allow us
to obtain similarly uniform estimates on the scattering data derived from
the Jost solutions.
Given the linear growth of $G_\star^+$ as
$\lambda \to 0$, in order to obtain $\lambda$-independent estimates while
studying the mapping properties of $G_\star^+$, we commonly work over polynomially
weighted $L^p$ ($1\leq p \leq \infty$) weighted spaces defined in definitions
\ref{defn2:Lps} and \ref{defn2:wLp}. In order to avoid introducing poles when
weighting by the reciprical of a polynomial, we introduce the notation
$\inn{x} := \sqrt{1+x^2}$\label{sym2:xbracket} to represent a linear weight.

\begin{defn}[$L^{p, s}$]\label{defn2:Lps}
	For $1< p < \infty$ and $s\in (-\infty, \infty)$, we define $L^{p, s}(\mathbb R)$
	to be the space of all
	measurable
	functions $f$ with the property that
	$\inn{\dotarg}^s f \in L^p(\mathbb R)$, and associate with $L^{p, s}(\mathbb R)$
	the norm $\| \dotarg \|_{L^{p,s}}$ given by
	\[
		\|f\|_{L^{p,s}} := \left(\int_{\mathbb R} \inn{x}^{sp} |f(x)|^p \right)^{1/p}.
	\]
	for each $f \in L^{p, s}(\mathbb R)$.
\end{defn}

\begin{rmk}
	In accordance with the notation used in \cite{Grafakos}, we use
	$L^{p, \infty}$ to denote the space $weak$-$L^p$. The space $L^{p, \infty}$
	should be thought of completely seperately from $L^{p,s}$ and should not be
	considered as a limit (in $s$) of $L^{p,s}$ spaces. For a definition of
	$L^{p, \infty}$, please see the appendix titled \hyperref[app:HA]{``Harmonic
	Analysis Results.''}
\end{rmk}

\begin{defn}[$\inn{\dotarg}^s L^p$]\label{defn2:wLp}
	Let $1 < p \leq \infty$. Then we use the notation
	$\inn{\dotarg}^s L^p(\mathbb R)$
	to indicate the collection of measurable functions $f$ with
	$\inn{\dotarg}^{-s} f \in L^p(\mathbb)$. Specifically,
	\[
		\inn{\dotarg}^s L^p(\mathbb R)
			:= \big\{ \inn{\dotarg}^s f ~:~ f \in L^p(\mathbb R) \big\}.
	\]
	The norm $\| \dotarg \|_{\inn{\dotarg}L^p}$ on the space
	$\inn{\dotarg}L^p(\mathbb R)$ is defined by
	$\| f \|_{\inn{\dotarg}L^p}:= \| \inn{\dotarg}^{-p} f \|_{L^p}$.
\end{defn}

\begin{rmk}
	Since we commonly work in the space $\inn{\dotarg} L^\infty(\mathbb R)$,
	it is worth highlighting the fact that $\inn{\dotarg} L^\infty(\mathbb R)$
	is the collection of all measurable functions $f$ for which
	$\inn{\dotarg} f$ is essentially bounded. That is,
	\[
		\| f \|_{\inn{\dotarg} L^\infty}
			= \esssup_{x\in \mathbb R} | \inn{x}^{-1} f(x) |
	\]
	is finite for all $f \in \inn{\dotarg} L^\infty(\mathbb R)$.
\end{rmk}

\begin{rmk}
	In cases involving functions of multiple variables or parameters, we
	sometimes use a subscript in conjunction with function space notation
	to avoid confusion. For example, $f \in L_\xi^p(\mathbb R)$ indicates
	that the function $f$ is $L^p$ integrable with respect to the variable
	$\xi$.\label{sym2:Lpxi}
\end{rmk}

In addition to considering the mapping properties of $G_\star^+$, we also
consider in this chapter the related operators $T_{\star, \lambda, u}$
(commonly denoted as $T_{\star}$ or $T_{\star, \lambda}$, for short) given by
\begin{align}\label{eqn2:Tdefn}
	T_{\star, \lambda, u} f(x)
		:= \big[ G_\star^+(\dotarg; \lambda) \big] * (u\,f)(x),
			\qquad \big( \star = L \text{, or } R \big)
\end{align}
as the integral equations \eqref{eq0:JostIE} can be reformulated as
\begin{subequations}
	\label{eq2:JostIEreform}
	\begin{align}
		\label{eq2:JostIEleftReform}
		\begin{pmatrix}
			1 \\
			e^{i\lambda x}
		\end{pmatrix}
			&= (I - T_{L, \lambda, u})
				\begin{pmatrix}
					M_1^+(x; \lambda, \delta) \\
					M_e^+(x; \lambda, \delta)
				\end{pmatrix} \\[0.3\baselineskip]
		\label{eq2:JostIErightReform}
		\begin{pmatrix}
			1 \\
			e^{i\lambda x}
		\end{pmatrix}
			&= (I - T_{R, \lambda, u})
				\begin{pmatrix}
					N_1^+(x; \lambda, \delta) \\
					N_e^+(x; \lambda, \delta)
				\end{pmatrix}
\end{align}
\end{subequations}

In considering a space of potentials $u$, we need to compensate
for the logarithmic singularity of $G_\star^+$ at $x = 0$ as well as the linear
growth (in $x$) of $G_\star^+$. In particular, the linear growth of the sum of
the residue terms of $G_\star^+$ for $\lambda = 0$ forces us to allow
solutions to \eqref{eq2:JostIEreform} which grow at most linearly (\textit{i.e.}
are $\inn{\dotarg}L^\infty$.) As we see in Proposition \ref{prop2:Tbnd}, requiring
$\inn{\dotarg}^2 u$ is $L^1$ \textit{and} also requiring that the convolution
of $\inn{\dotarg} u$ with $\log_+\left(\frac{1}{|x|}\right)$ be essentially bounded
ensures that $T_{\star, \lambda}$ is a bounded operator on
$\inn{\dotarg}L^\infty(\mathbb R)$ for all real $\lambda$. However, in order
to ensure that solutions to \eqref{eq2:JostIEreform} satisfy the asymptotic
conditions imposed on the Jost solutions\textemdash{}necessary to prove the
equivalence of the Jost solutions and solutions to
\eqref{eq2:JostIEreform}\textemdash{}we need $u$ to satisfy the even stronger
decay condition that $\inn{\dotarg}^3 u$ is $L^1$. Please see Section
\ref{sec4:equiv} for why such strong decay is needed.

In proving the equivalence of Jost solutions and solutions to the
integral equations \ref{eq2:JostIEreform} in Section \ref{sec4:equiv},
we also need the upper boundary values of solutions to the integral equations
\ref{eq0:JostIE} to exist in an $L^2$ sense. For reasons that become
apparent in Sections \ref{sec3:CauchyTrans} and \ref{sec3:BndE}, doing so
also requires $u$ to be $L^2$ integrable. Keeping our entire list
of desired properties for $u$ in mind, we select the space $X$ of potentials
$u$ as follows:

\begin{defn}\label{defn2:X}
	Denote by $X$ the space of all measurable functions $u$ for which
	\[
		\|u\|_X
			:= \nm{\inn{\dotarg}^4 u}_{L^2}
	\]
	is finite. That is, $X = \inn{\dotarg}^{-4} L^2(\mathbb R)
	= L^{2,4}(\mathbb R)$.
\end{defn}

\begin{rmk}\label{rmk2:PostX}
	To see that $u \in X$ actually has all of the required properties,
	we first note that by the Cauchy-Schwarz inequality,
	\begin{align*}
		\nm{ \inn{\dotarg}^3 u }_{L^1}
			= \inn{\inn{\dotarg}^{-1}, \, \inn{\dotarg}^4 \, u }_{L^2}
			= \nm{\inn{\dotarg}^{-1}}_{L^2}
				\nm{\inn{\dotarg}^{4} \, u}_{L^2}
			< \infty,
	\end{align*}
	where we use $\inn{\dotarg, \dotarg }_{L^2}$ to denote the $L^2$ inner
	product. Hence, $u \in X$ implies $u \in L^{1,2}(\mathbb R)$. A similar
	use of the Cauchy-Schwarz inequality also shows that the convolution
	of $\log_+\left(\frac{1}{|x|}\right)$ with $\inn{\dotarg} u$ is bounded
	by $4 \|u\|_X$ for all $x \in \mathbb R$.
\end{rmk}

We explore in Section \ref{sec2:bndness} the boundedness and asymptotic
properties of $G_\star^+$ and $T_\star$ needed to that the direct scattering
map
$\mathscr D$ is both well-defined and Lipschitz continuous. In Section
\ref{sec2:diff} we continue our exploration of the mapping properties
of both $G_\star$ and $T_\star$ by considering their continuity and
differentiability in $\lambda$, which we use while verifying the
Lipschitz continuity of $\mathscr D$.
\end{document}


% !TeX root = ../documentation.tex

% Davis Putnam in own word

\chapter{Scientific Basics}
\label{ch:sciBasics}
% cSpell:disable
% Das Ziel dieser Arbeit besteht in der Visualisierung des \textit{Davis-Putman algorithm}us, der das sogenannte N damen Problem lösen soll. Dafür muss zuerst ein allgemeines Verständnis zu diesem Algorithmus und dem mathematischen Problem geschaffen werden. In diesem Kapitel wird aus diesem Grund dieses fundamentale Wissen zusammengefasst, um eine Basis für die weiterführende Entwicklung zu schaffen. Dafür spielt unter anderem die Deklarierung des mathematischen Problems eine Rolle, damit dieses vom \textit{Davis-Putman algorithm}us gelöst werden kann.
% cSpell:enable
The purpose of this work is to visualize the \textit{Davis-Putnam algorithm} solving the so-called \textit{N-Queens Problem}. Therefore a general understanding of this algorithm and the mathematical problem has to be created.

This chapter summarizes the fundamental knowledge that is needed in order to create a basis for further development. Among other things, the definition of the mathematical problem is discussed, so that a possible solution can be found by the \textit{Davis-Putnam algorithm}.

\section{Basics of Propositional Logic}
\label{sec:sciProLogic}
Before the algorithm can be examined in more detail, a few mathematical terms have to first be explained.

%TODO : Check English
\paragraph{Propositional Variable}
\emph{Propositional Variables} are atomic propositions, which can be used with the following junctures.
\begin{enumerate}
\item $\neg a$ \quad\quad\ represents \quad \textsl{not} $a$
      \vspace*{-0.2cm}

\item $a \wedge b$ \,\quad\ represents  \quad $a$ \textsl{and} $b$
      \vspace*{-0.2cm}

\item $a \vee b$ \,\quad\ represents \quad $a$ \textsl{or} $b$
      \vspace*{-0.2cm}

\item $a \rightarrow b$   \quad represents \quad \textsl{if} $a$ \textsl{then} $b$
      \vspace*{-0.2cm}

\item $a \leftrightarrow b$ \quad represents \quad  $a$ \textsl{if and only if} $b$
\end{enumerate}

\paragraph{Set of propositional logical variables}
A set $\mathcal{P}$ is defined as the \emph{Set of propositional logical variables}. Typically the set consists of small types from the Latin alphabet, which also may be indexed.\\
For example: $\mathcal{P} := \{\ p,\ q,\ r,\ p_1,\ p_2,\ p_3\ \}$

\paragraph{Set of propositional logical formulas}
Propositional logical formulas are words, which are created from the alphabet $\mathcal{A}:= \mathcal{P} \cup \{\top,\bot,\neg,\vee,\land,\rightarrow,\leftrightarrow,(,)\}$ \\
The \emph{set of propositional logical formulas} $\mathcal{F}$ is defined by induction:
\begin{enumerate}
  \item $\top \in \mathcal{F}$ and $\bot \in \mathcal{F}$ \\
  Here, $\top$ is called Verum and stands for the formula, which is always true. $\bot$ is called Falsum and stands for the formula which is always false.
  \item If $p \in \mathcal{P}$, then $p \in \mathcal{F}$ also applies. \\
  Every propositional logical variable is also a propositional logical formula.
  \item If $f \in \mathcal{F}$, then $\neg f \in \mathcal{F}$ also applies. \\
  The formula $\neg f$ is called the negation of $f$.
  \item If $f_1, f_2 \in \mathcal{F}$, then \\
  $(f_1 \vee f_2) \in \mathcal{F}$ (Disjunction of $f_1$ and $f_2$) \\
  $(f_1 \land f_2) \in \mathcal{F}$ (Conjunction of $f_1$ and $f_2$) \\
  $(f_1 \rightarrow f_2) \in \mathcal{F}$ (Implication of $f_1$ and $f_2$) \\
  $(f_1 \leftrightarrow f_2) \in \mathcal{F}$ (Biconditional of $f_1$ and $f_2$)
  also applies.
\end{enumerate}
The set $\mathcal{F}$ is the smallest subset of words created from alphabet $\mathcal{A}$, which has the previous listed characteristics.

\paragraph{Literal}
A propositional logic formula $f$ is called a \emph{literal}, if one of the following cases is true.
\begin{enumerate}
  \item $f = \top$ or $f = \bot$
  \item $f = p$, where $p$ is a propositional variable. If this is the case, it is called a positive literal.
  \item $f = \neg p$, where $p$ is a propositional variable. Then it is called a negative literal.
\end{enumerate}
The set of all literals is called $\mathcal{L}$.

\paragraph{Clause}
A propositional logic formula $C$ is called a \emph{clause} if it has the following structure.
\\[0.2cm]
\hspace*{1.3cm} $C = l_1 \vee \cdots \vee l_r$ \\[0.2cm] Here, $l_i$ is a literal for every value $i \in \{1,\; ...,\; r\}$.
\\[0.2cm]
The set of all clauses is called $\mathcal{K}$.

\paragraph{Conjunctive normal form} A formula $F$ is in \emph{conjunctive normal form} if and only if $F$ is a conjunction of clauses:
\\[0.2cm]
\hspace*{1.3cm} $F = K_1 \land \cdots \land K_n$, \\[0.2cm]
where $K_i$ is a clause for all $i = 1, \cdots, n$.

\paragraph{Propositional logic interpretation}
The function $\mathcal{I} : \mathcal{P} \rightarrow \mathbb{B}$ is called \emph{propositional logic interpretation}, which assigns a truth value $\mathcal{I}(p) \in \mathbb{B}$ to each proposition-logical variable $p\in \mathcal{P}$

\paragraph{Satisfiable}
There is set of propositional logic formulas $K$. If there is an interpretation $K$ so that all formulas of the set $K$ are satisfied so that $\mathcal{I}(f) = \texttt{True}$ for all propositional logic formulas $f \in K$, then the set $K$ is \emph{satisfiable}. If this is not the case, then the set $K$ is not satisfiable.

\paragraph{Tautology}
A propositional logic formula $f$ is a \emph{tautology} if and only if $\mathcal{I}(f) = \texttt{True}$ for every interpretation $\mathcal{I}$. This case is written as $\models f$.

\paragraph{Solution}
If there is an interpretation $\mathcal{I}$ that satisfies a set of propositional logic formulas $K$, then $\mathcal{I}$ is a \emph{solution} of $K$.
%TODO Notation of Solution \mathcal{I} --> don't know which Notation

\section{The Algorithm of Davis-Putnam}
\label{sec:sciDavisPutnam}
% cSpell:disable
% Der \textit{Davis-Putman algorithm}us ist ein Verfahren zur Berechnung einer Lösung von aussagelogischen Klauselmengen. Bei sehr kleinen Klauselmengen kann dies leicht bestimmt werden, wie in den zwei folgenden Beispielen zu sehen ist.
% cSpell:enable
The \textit{Davis-Putnam algorithm} is a method for calculating a solution of a set of propositional clauses. With clause sets that contain just one literal per clause this can be easily determined, as can be seen in the following two examples.
\\[0.2cm]
\hspace*{1.3cm} $K_1 = \bigl\{\; \{r\},\; \{\neg s\},\; \{t\},\; \{\neg u\}, \; \{\neg v\} \;\bigr\}$
\\[0.2cm]
% cSpell:disable
%kann auch als aussagelogische Formel geschrieben werden.
% cSpell:enable
$K_1$ can also be written as a propositional logic formula.
\\[0.2cm]
\hspace*{1.3cm} $r \land \neg s \land t \land \neg u \land \neg v$.
\\[0.2cm]
% cSpell:disable
% Es ist erkennbar, dass diese Formel lösbar ist, indem $r$ und $t$ \enquote{wahr} und $s$, $u$ und $v$ den Wert \enquote{falsch} haben. Als Gegenbeispiel dazu ist $K_2$ zu betrachten.
% cSpell:enable
It is obvious that this formula is solvable by $r$ and $t$ \enquote{true} and $s$, $u$ and $v$ having the value \enquote{false}.
As a negative example we consider the set $K_2$, which is defined as follows:
\\[0.2cm]
\hspace*{1.3cm} $K_2 = \bigl\{\; \{r\},\; \{\},\; \{t\} \;\bigr\}$
\\[0.2cm]
$K_2$ can also be written as a propositional logic formula.
\\[0.2cm]
\hspace*{1.3cm}
$r \land \bot \land t$.
\\[0.2cm]
% cSpell:disable
% Eine leere Klammer bedeutet in der Aussagelogik ein Falsum, wodurch $K_2$ unerfüllbar ist. Bei sehr großen Klauselmengen ist es meist nicht mehr auf dem ersten Blick zu sehen, so dass Algorithmen wie dieser eingesetzt werden. Doch um nun einen Schritt tiefer setzen zu können, müssen zwei Definitionen zuvor eingeführt werden.
% cSpell:enable
The empty set in the set of clauses $K_2$ is interpreted as a $\bot$ in the propositional logic, making it impossible to satisfy $K_2$. The set of clauses $K_1$ can easily be satisfied, since it only contains clauses with a single literal. Once the clauses of $K_1$ contain more literals it gets more complex to satisfy. For these algorithms like the \textit{Davis-Putnam algorithm} are used. But before we get to the details, two definitions have to be introduced first \cite{Zhang2000}.

\paragraph{Unit clause}
% cSpell:disable
% Eine Klausel $C$ ist eine Unit-Klausel, wenn diese nur aus einem Literal, also aus einer Aussagevariablen besteht.
% cSpell:enable
A clause $C$ is a \emph{unit clause} if it contains of only a single literal, i.e. a variable or a negated variable.

\paragraph{Trivial clause sets}
% cSpell:disable
% Eine triviale Klauselmenge kann nur vorkommen, wenn einer der beiden Fälle eintritt.
% cSpell:enable
A set of clauses is \emph{trivial} if and only if one of the following two cases holds.

\begin{enumerate}
  % cSpell:disable
  % $K$ enthält die leere Klausel und ist somit unerfüllbar
  % cSpell:enable
  \item The set of clauses $K$ contains the empty set and is therefore unsatisfiable.
  % cSpell:disable
  % Die Unit-Klauseln beinhalten immer verschiedene Aussagevariablen, so dass entweder nur die Klausel $\{p\}$ oder $\{\neg p\}$ vorkommen kann. Ist dies der Fall, kann eine Lösung für die Klauselmenge bestimmt werden.
  % cSpell:enable
  \item The unit clauses always contain different propositional variables, so that only the clause $\{p\}$ or $\{\neg p\}$ can occur. If this is the case, a solution for the clause set can be determined.
\end{enumerate}

% cSpell:disable
% Damit einer dieser beiden Fälle nun eintreten kann, müssen die Klauselmengen mit der Hilfe folgender drei Möglichkeiten so vereinfacht werden, dass diese nur aus Unit-Klauseln bestehen.
% cSpell:enable
In order for one of these two cases to occur, the clause sets have to be simplified with the help of the following three options so that they consist only of unit clauses.

\begin{enumerate}
  \item Cut Rule
  \item Subsumption
  \item Case Differentiation
\end{enumerate}

\subsection{Simplification with the Cut Rule}
\label{sub:sciDavisPutnamCutRule}
To simplify a set of clauses $K$ with $C_1 \cup \{\; p\; \}$, $C_2 \cup \{\; \neg p\; \} \in K$ the cut rule can be used. Let's say we have two clauses $C_1$, $C_2$ and a variable $p$, then a typical application of the cut rule is:
\\[0.2cm]
\hspace*{1.3cm} $\dfrac{C_1 \cup \{\; p\; \} \;\;\;\;\;\; C_2 \cup \{\; \neg p\; \}}{C_1 \cup C_2}$
\\[0.2cm]
In this case the result clause will in general have more literals than $C_1 \cup \{\; p\; \}$ or $C_2 \cup \{\; \neg p\; \}$ alone. Because if the clause $C_1 \cup \{\; p\; \}$ contains $m + 1$ literals and $C_1 \cup \{\; p\; \}$ contains $n + 1$ literals, then the union $C_1 \cup C_2$ can have upto $m + n$ literals in total. In general $m + n$ may be bigger than $m + 1$ or $n + 1$. The clause can be smaller than previously if both sets contain the same literals, but it is only granted to be smaller if $m = 0 \lor n = 0$. This is the case for unit clauses. Therefore we will only allow the use of the cut rule if one of the clauses is a unit clause. These cuts will be called \emph{unit cuts}. To be able to do those unit cuts with a unit clause $\{\; l\; \}$ on all clauses of a set of clauses $K$, we define the function
\\[0.2cm]
\hspace*{1.3cm} $\texttt{unitCut}: 2^{\mathcal{K}} \times L \to 2^{\mathcal{K}}$
\\[0.2cm]
so that for a set of clauses $K$ and a literal $l$ the function $\texttt{unitCut}(K,\; l)$ will simplify the set of clauses as much as possible by using unit cuts:
\\[0.2cm]
\hspace*{1.3cm} $\texttt{unitCut}(K,\; l) = \{\; C \setminus \{\; \bar{l}\; \}\; |\; C \in K\; \}$
\\[0.2cm]
The resulting set of clauses will have the same amount of clauses as $K$. Only the clauses $C \in K$ where $\bar{l} \in C$ were affected and got that element removed \cite{Stroetman2019}.

\subsection{Simplification with Subsumption}
\label{sub:sciDavisPutnamSubsumption}
For further simplification of the set of clauses we will use \emph{subsumption}. The idea is simple and can be shown with the following example:
\\[0.2cm]
\hspace*{1.3cm} $K = \bigl\{\; \{\; p,\; \neg q \;\},\; \{\; p\; \}\;\bigr\} \cup M$
\\[0.2cm]
It is clear that the clause $\{\; p\; \}$ implies the clause $\{\; p,\; \neg q \;\}$, because if $\{\; p\; \}$ is satisfied, then $\{\; p,\; \neg q \;\}$ will be satisfied too. That's because
\\[0.2cm]
\hspace*{1.3cm} $\models p \to p \lor \neg q$
\\[0.2cm]
is given. With that in mind we can say that we can subsume a clause $C$ with a unit clause $U$ if $U \subseteq C$. That means if we have a set of clauses $K$ with $C \in K \land U \in K$ and $U$ subsumes $C$, we can remove the clause $C$ from $K$ to reduce its size. We define a function
\\[0.2cm]
\hspace*{1.3cm} $\texttt{subsume}: 2^{\mathcal{K}} \times L \to 2^{\mathcal{K}}$
\\[0.2cm]
that receives a set of clauses $K$ and a literal $l$. It will simplify $K$ by subsuming with the unit clause $\{\; l\; \}$:
\\[0.2cm]
\hspace*{1.3cm} $\texttt{subsume}(K,\; l) = \{\; C \in K\; |\; l \notin C\} \cup \bigl\{\{\; l\; \bigr\}\}$
\\[0.2cm]
We have to add the unit clause to the set of clauses, because $l \in U$. Resulting in $U$ being removed from $K$ at first too \cite{Stroetman2019}.

\subsection{Simplification with Case Differentiation}
\label{sub:sciDavisPutnamCaseDiv}
% cSpell:disable
% Die Basis für das Prinzip der Fallunterscheidung bildet folgender Satz.
% cSpell:enable
The following theorem forms the basis for the principle of case differentiation.

\paragraph{Theorem}
% cSpell:disable
% Die Klauselmenge K ist genau dann erfüllbar, wenn die Klausel $K \cup \bigl\{\{p\}\bigr\}$ oder $K \cup \bigl\{\{\neg p\}\bigr\}$ erfüllbar ist.
% cSpell:enable
The set of clauses $K$ can only be satisfied if and only if $K \cup \bigl\{\{p\}\bigr\}$ or $K \cup \bigl\{\{\neg p\}\bigr\}$ can be satisfied.

% cSpell:disable
% Für die Vereinfachung wird zu Beginn also eine Aussagenvariable p ausgewählt, die in der Klauselmenge vorkommt. Danach werden die beiden oben genannten Klauselmengen gebildet und versucht, für eine der beiden eine Lösung zu finden. Ist dieser Versuch erfolgreich, ist das Ergebnis automatisch die Lösung von $K$. Falls keine gefunden wird, ist $K$ unlösbar.
% TODO: Keine Ahnung ob hier Beweis einfügen soll
% cSpell:enable
For simplification, a propositional variable $p$ is selected at the beginning, which occurs in the clause set. Then the two clause sets mentioned above are formed and an attempt is made to find a solution for one of them. If this attempt is successful, the result is automatically a solution of $K$. If none is found, $K$ is not satisfiable.

\subsection{The Davis-Putnam Method}
\label{sub:sciDavisPutnamMethod}
% cSpell:disable
% Durch die Wissensgrundlage, die zuvor geschaffen wurde, ist es nun möglich, das Vorgehen des \textit{Davis-Putman algorithm}us zu skizzieren. Mit der Hilfe der Schnittregel und der Subsumption wird die Klauselmenge $K$ soweit es möglich ist, vereinfacht. Falls bereits nach diesem Schritt $K$ trivial ist, ist das Verfahren beendet. Andernfalls wird eine aussagelogische Variable p ausgewählt, die in K vorkommt. Dann wird rekursiv versucht, die Klauselmenge $K \cup \bigl\{\{p\}\bigr\}$ zu lösen, um eine Lösung für K zu finden. Wenn auch hier keine Lösung gefunden wurde, wird dasselbe mit dem negierten $p$ versucht. Scheitert auch dieser Versuch, ist K unlösbar.
% cSpell:enable
The theoretical foundation that was previously created makes it possible to sketch the procedure of the \textit{Davis-Putnam algorithm}. With the help of the intersection rule and the subsumption, the clause set $K$ is simplified as far as possible. If already after this step $K$ is trivial, the procedure is finished. Otherwise a propositional logical variable p is selected, which occurs in $K$. Then a recursive attempt is made to solve the clause set $K \cup \bigl\{\{p\}\bigr\}$ in order to find a solution for $K$. If no solution was found here either, the same is tried with the negated $p$. If this attempt also fails, $K$ is unsatisfiable. A possible recursive implementation of the method can be seen in listing \ref{code:recursiveDavisPutnam} \cite{Zhang2000}, \cite{Stroetman2019}.
% TODO: find more sources

\begin{listing}[h!]
  \textbf{function} Satisfiable( clause set $S$ ) \textbf{return} boolean\\
    \hspace*{0.5cm} \textit{/* unit propagation */}\\
    \hspace*{0.5cm} \textbf{repeat}\\
      \hspace*{1.0cm} \textbf{for each} unit clause $L$ in $S$ \textbf{do}\\
        \hspace*{1.5cm} \textit{/* unit subsumption */}\\
        \hspace*{1.5cm} delete from $S$ every clause containing $L$\\
        \hspace*{1.5cm} \textit{/* unit resolution */}\\
        \hspace*{1.5cm} delete $\bar{L}$ from every clause of $S$ in which it occurs\\
      \hspace*{1.0cm} \textbf{od}\\
      \hspace*{1.0cm} \textbf{if} $S$ is empty \textbf{then}\\
        \hspace*{1.5cm} \textbf{return} true\\
      \hspace*{1.0cm} \textbf{else if} a clause becomes $\{\}$ in $S$ \textbf{then}\\
        \hspace*{1.5cm} \textbf{return} false\\
      \hspace*{1.0cm} \textbf{fi}\\
    \hspace*{0.5cm} \textbf{until} no further changes result\\
    \hspace*{0.5cm} \textit{/* splitting */}\\
    \hspace*{0.5cm} choose a literal $L$ occurring in $S$\\
    \hspace*{0.5cm} \textbf{if} Satisfiable ($S \cup \{\{\bar{L}\}\}$) \textbf{then}\\
      \hspace*{1.0cm} \textbf{return} true\\
    \hspace*{0.5cm} \textbf{else if} Satisfiable ($S \cup \{\{L\}\}$) \textbf{then}\\
      \hspace*{1.0cm} \textbf{return} true\\
    \hspace*{0.5cm} \textbf{else}\\
      \hspace*{1.0cm} \textbf{return} false\\
    \hspace*{0.5cm} \textbf{fi}\\
  \textbf{end function}
  \caption{A simple Davis–Putnam algorithm \cite{Zhang2000}}
  \label{code:recursiveDavisPutnam}
\end{listing}

\section{N-Queens Problem}
\label{sec:sciQueens}
% cSpell:disable
% Das n Königinnen Problem ist das verallgemeinerte mathematische Problem bezogen auf ein Schachbrett, dass n \times n Felder besitzt. Ein spezielles Beispiel dazu wäre das 8 Damen Problem, welches auf dem standardisierten Schachbrett abgebildet wird. Allgemein handelt das Problem davon, n Damen auf einem n \times n Schachbrett so zu platzieren, dass keine in ihrem Zug behindert werden würde. Eine Königin in einem normalen Schachspiel kann sowohl diagonal, als auch vertikal und horizontal ihre Züge ziehen. Dieses Zugmuster kann in Figure \label{fig:queens-problem} genauer angeschaut werden. Zusammengefasst heißt dies also, dass immer nur eine Dame auf ihrer vertikalen, horizontalen und diagonalen Linie sein darf, um sich nicht gegenseitig zu behindern. Dabei wird in diesem Problem davon ausgegangen, dass jede Dame jede andere angreifen kann und die Feldfarben ignoriert werden.
% cSpell:enable
The N-Queen problem is about how to place n queens on an $n \times n$ chessboard so that no queen can capture another queen. A special example would be the 8-Queens Problem, which is related to the standardized chessboard. A queen in a normal game of chess can move diagonally, vertically and horizontally. This move pattern can be seen in Figure \ref{fig:queens-problem}. In summary, this means that there is only one queen allowed on every vertical, horizontal and diagonal line at a time so that they do not interfere with each other. In this problem it is assumed that any queen can attack any other queen and the field colors are ignored. This problem can be solved by several backtracking algorithms such as the \textit{Davis-Putnam algorithm} \cite{OMCA2019}, \cite{GeeksGeeks2019} \cite{Stroetman2019}.

\begin{figure}[!ht]
  \centering
  \setlength{\unitlength}{1.0cm}
  \begin{picture}(10,9)
    \thicklines
    \put(1,1){\line(1,0){8}}
    \put(1,1){\line(0,1){8}}
    \put(1,9){\line(1,0){8}}
    \put(9,1){\line(0,1){8}}
    \put(0.9,0.9){\line(1,0){8.2}}
    \put(0.9,9.1){\line(1,0){8.2}}
    \put(0.9,0.9){\line(0,1){8.2}}
    \put(9.1,0.9){\line(0,1){8.2}}
    \thinlines
    \multiput(1,2)(0,1){7}{\line(1,0){8}}
    \multiput(2,1)(1,0){7}{\line(0,1){8}}
    \put(4.15,6.15){{\chess Q}}
    \multiput(5.25,6.5)(1,0){4}{\vector(1,0){0.5}}
    \multiput(3.75,6.5)(-1,0){3}{\vector(-1,0){0.5}}
    \multiput(5.25,7.25)(1,1){2}{\vector(1,1){0.5}}
    \multiput(5.25,5.75)(1,-1){4}{\vector(1,-1){0.5}}
    \multiput(3.75,5.75)(-1,-1){3}{\vector(-1,-1){0.5}}
    \multiput(3.75,7.25)(-1,1){2}{\vector(-1,1){0.5}}
    \multiput(4.5,7.25)(0,1){2}{\vector(0,1){0.5}}
    \multiput(4.5,5.75)(0,-1){5}{\vector(0,-1){0.5}}
  \end{picture}
  \vspace*{-1.0cm}
  \caption{Movement pattern of a queen on an 8 by 8 board \cite{Stroetman2019}}
  \label{fig:queens-problem}
\end{figure}

\subsection{N-Queens Problem as Propositional Formula}
Before we can find a solution for the \textit{N-Queens Problem}, we need to define the problem as a propositional logic formula. For that we will say that the variable $Q_{x,y}$ represents the queen in row $x$ on column $y$. If for example $Q_{1,2}$ is true a queen will be placed on row 1 and column 2 otherwise this square remains empty. Now all that is left is the creation of the set of clauses $K$ that describes the \textit{N-Queens Problem}. Therefore we define some functions to help us specify the problem as such:

\paragraph{atMostOne}
The function atMostOne will receive a set of variables $P$ and return a set of clauses $K$ that express the fact that only one of the variables $p \in P$ can be true. We define it to support the following functions.
\\[0.2cm]
\hspace*{1.3cm}$\texttt{atMostOne}:\ \mathcal{P} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm}$\texttt{atMostOne}(P) := \bigl\{\ \{\ \neg p_1,\ \neg p_2 \}\ :\ p_1, p_2 \in P\ |\ p_1 \neq p_2\ \bigr\}$
\\[0.2cm]
This works, because if one variable is said to be true then the other variable has to be false, since either one or the other needs to be false.

\paragraph{atMostOneInRow}
This function receives a number $n$ for the total amount of queens and a number $r \in \{1 .. n\}$ for the row and return a set of clauses $K$ that express the fact that only one queen can be placed in row $r$.
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInRow}:\ \mathcal{N} \times \mathcal{N} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInRow}(r,\ n) := \texttt{atMostOne}(\{\ Q_{r,i} :\ i \in \{1\ ..\ n\}\ \})$

\paragraph{oneInColumn}
This function receives a number $n$ for the total amount of queens and a number $c$ where $c \leq n$ for the column and returns a set of clauses $K$ that express the fact that at least one queen has to be placed in the column $c$. Because if only one queen can be placed per row, every column needs at least one queen to have $n$ queens on the chessboard.
\\[0.2cm]
\hspace*{1.3cm} $\texttt{oneInColumn}:\ \mathcal{N} \times \mathcal{N} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm} $\texttt{oneInColumn}(c,\ n) := \bigl\{\ \{\ Q_{i,c} :\ i \in \{1\ ..\ n\}\ \}\ \bigr\}$

\paragraph{atMostOneInUpperDiagonal}
This function returns a set of clauses $K$ that express the fact that only one queen can be placed in the upper diagonal, for a given number $n$ and $k \in \{3\ ..\ 2 * n - 1\}$. The number $k$ helps with calculating which combination of row and column is part of the diagonal.
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInUpperDiagonal}:\ \mathcal{N} \times \mathcal{N} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInUpperDiagonal}(k,\ n) :=$
\\
\hspace*{2.6cm} $\texttt{atMostOne}(\{\ Q_{x,y} :\ x,y \in \{1\ ..\ n\}\ |\ x + y = k\ \})$
\\[0.2cm]
This works because for an upper diagonal when increasing x by one we reduce y by one and vice versa. So if we create the sum of x and y the result will be the same for each tile of the same diagonal as following equations show.
\\[0.2cm]
\hspace*{1.3cm} $x + y = x + 1 + y - 1$\\
\hspace*{1.3cm} $x + y = x - 1 + y + 1$
\\[0.2cm]
Starting with $k = 3$, because $Q_{1,2}$ and $Q_{2,1}$ are the first upper diagonal, and ending with $k = 2 * n - 1$, because $Q_{n - 1, n}$ and $Q_{n, n - 1}$ form the last diagonal.

\paragraph{atMostOneInLowerDiagonal}
This function returns a set of clauses $K$ that express the fact that only one queen can be placed in the lower diagonal, for a given number $n$ and $k \in \{-(n - 2)\ ..\ n - 2\}$. As before the number $k$ helps with calculating which combination of row and column is part of the diagonal.
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInLowerDiagonal}:\ \mathcal{N} \times \mathcal{N} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm} $\texttt{atMostOneInLowerDiagonal}(k,\ n) :=$
\\
\hspace*{2.6cm} $\texttt{atMostOne}(\{\ Q_{x,y} :\ x,y \in \{1\ ..\ n\}\ |\ x - y = k\ \})$
\\[0.2cm]
Here it is similar to the upper diagonals, but with the change that both x and y either increase or decrease by one. Now the difference between x and y is the same for each tile of the same diagonal as following equations show.
\\[0.2cm]
\hspace*{1.3cm} $x - y = x + 1 - y - 1 = (x + 1) - (y + 1)$\\
\hspace*{1.3cm} $x - y = x - 1 - y + 1 = (x - 1) - (y - 1)$
\\[0.2cm]
Starting with $k = -(n - 2)$, because $Q_{1,n - 1}$ and $Q_{2,n}$ are the first lower diagonal, and ending with $k = n - 2$, because $Q_{n - 1, 1}$ and $Q_{n, 2}$ form the last diagonal.

\paragraph{queensClauses}
With the functions above, we finally can define the complete propositional formula for the \textit{N-Queens Problem} for a given number $n$ in form of a set of clauses $K$.
Since at least one queen has to be placed in every column and only one is allowed per row, exactly one queen will be placed per column and a set of clauses that express that only one queen can be placed per column is not needed.
\\[0.2cm]
\hspace*{1.3cm} $\texttt{queensClauses}: \mathcal{N} \to 2^{\mathcal{K}}$
\\[0.2cm]
\hspace*{1.3cm} $\texttt{queensClauses}(n) := \bigcup\limits_{i=1}^{n}(\texttt{atMostOneInRow}(i, n)\ \cup\ $
%\\[0.1cm]
%\hspace*{6.5cm}
$\texttt{oneInColumn}(i, n))\ \cup\ $
\\[0.1cm]
\hspace*{6.1cm} $\bigcup\limits_{i=3}^{2 * n - 1}\ \texttt{atMostOneInUpperDiagonal}(i, n)\ \cup\ $
\\[0.1cm]
\hspace*{5.8cm} $\bigcup\limits_{i=-(n - 2)}^{n - 2}\texttt{atMostOneInLowerDiagonal}(i, n)$


\documentclass[10pt]{article}

\usepackage{amsmath}
\usepackage{natbib}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{fancyhdr}
\usepackage{syntonly}
\usepackage{graphicx}

\title{My title}
\author{Dr. Jarad Niemi}
%\institution{Iowa State University}
\date{\today}

\begin{document}

\maketitle
\newpage

\section{First section}

The header used in this document is one I used for homework to reduce margins. For a journal article we will uncomment all the header and manual adjustment of margins.

Here is a label to Figure \ref{fig:2009} and one to Figures \ref{fig:n1}-\ref{fig:n2} in Section \ref{sec:subsection} as well as to Table \ref{20070717t1} in the Section \ref{sec:subsubsection}.

\begin{figure}[htbp]
\centering
\includegraphics[width=5in]{2009}
\begin{minipage}{.85\textwidth}
\caption{Traceplots for $Y$.}
\label{fig:2009}
\end{minipage}
\end{figure}

\subsection{A subsection \label{sec:subsection}}

% 2 Figures side-by-side
\begin{figure}
\begin{minipage}[b]{0.5\linewidth} % A minipage that covers half the page
\centering
\includegraphics[width=6cm]{n1}
\caption{Histogram of proportion of MCMC draws below $k$.}\label{fig:n1}
\end{minipage}
\hspace{0.5cm} % To get a little bit of space between the figures
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=6cm]{n2}
\caption{Histogram of proportion of MCMC draws below $W$.}\label{fig:n2}
\end{minipage}
\end{figure}

\subsubsection{A subsubsection \label{sec:subsubsection}}

\begin{table}[htbp]
\centering
\caption{Qualitative results for Gibbs sampling of $\phi$ in constant DLM $\{1,\phi, .0001,1\}$.}
\label{20070717t1}
\vspace{11pt}
\begin{tabular}{l|cc}
\hline
& \multicolumn{2}{c}{$\phi$} \\
T & .5 & .99 \\
\hline
$10^1$ & \\

\hline
\end{tabular}
\end{table}

\section*{Un-numbered section}

Use the asterisk to not have a number on the section. Finally here is a reference to a paper \citep{Niem:Smit:Bank:test:2008}.

\bibliographystyle{natbib}
\bibliography{jarad}

\end{document}


The generalized extreme value distribution (GEV) includes all three
types of extreme value distributions: Type I (Gumbel), type II
(Fr\'{e}chet), and type III (Weibull). Empirically, the scores of some
sequence alignment algorithms appear to follow GEV distributions.  The
\eslmod{gev} module is used in estimating the statistical significance
of such scores.

Most local sequence alignment scores follow the Gumbel distribution.
Easel's \eslmod{gumbel} module applies specifically to the Gumbel. The
\eslmod{gev} module is used for Type II or III extreme value
distributions, or for determining which of the three types of
distribution that a dataset best fits.

\subsection{The gev API}

The \eslmod{gev} API consists of the following functions:

\vspace{0.5em}
\begin{center}
\begin{tabular}{ll}\hline
    \multicolumn{2}{c}{\textbf{evaluating densities and distributions:}}\\
\ccode{esl\_gev\_pdf()}     & Returns the probability density, $P(S=x)$.\\
\ccode{esl\_gev\_logpdf()}  & Returns the log of the pdf, $\log P(S=x)$.\\
\ccode{esl\_gev\_cdf()}     & Returns the cumulative probability distribution, $P(S \leq x)$.\\
\ccode{esl\_gev\_logcdf()}  & Returns the log of the cdf, $\log P(S \leq x)$.\\
\ccode{esl\_gev\_surv()}    & Returns right tail mass, 1-cdf, $P(S > x)$\\
\ccode{esl\_gev\_logsurv()} & Returns log of 1-cdf, $\log P(S > x)$.\\
    \multicolumn{2}{c}{\textbf{sampling:}}\\
\ccode{esl\_gev\_Sample()}  & Returns a GEV-distributed random sample.\\
    \multicolumn{2}{c}{\textbf{maximum likelihood parameter fitting:}}\\
\ccode{esl\_gev\_FitComplete()} & Estimates GEV parameters from complete data.\\
\end{tabular}
\end{center}
\vspace{0.5em}

The Gumbel distribution depends on three parameters, $\mu$, $\lambda$,
and $\alpha$. When these parameters are known, the statistical
significance (P-value) of a single score $x$ is $P(S>x)$, obtained by
a call to \ccode{esl\_gev\_surv()}.  The E-value for obtaining that
score or better in searching a database of $N$ sequences is just
$NP(S>x)$.

When the parameters are unknown, they can be estimated from scores
obtained from comparisons of simulated random data. The
\ccode{esl\_gev\_FitComplete()} function performs maximum likelihood
parameter fitting \citep{Coles01}.

\subsection{Example of using the gev API}

Below is a code example that samples 10,000 data points from a
Fr\'{e}chet distribution with $\mu=-20$, $\lambda=0.4$, $\alpha=0.1$;
reports the min and max samples, and the probability mass to the left
of the min and to the right of the max (both of which should be about
$\frac{1}{10000}$, since we took 10,000 samples); and then fits those
simulated data to a Gumbel and reports the fitted $\mu$ and $\lambda$:

\input{cexcerpts/gev_example}

\subsection{GEV densities}

The probability density function (pdf) and the cumulative distribution
function (cdf) of the generalized extreme value distribution are
\citep{Coles01}:

\begin{eqnarray}
P(X=x) & = & \lambda \left[ 1 + \alpha \lambda (x - \mu) \right]^{-\frac{\alpha+1}{\alpha}}
       \exp \left\{ - \left[ 1 + \alpha \lambda (x - \mu)
       \right]^{-\frac{1}{\alpha}} \right\}
\\%
\label{eqn:gev_density}
P(X \geq x) & = & \exp \left\{ - \left[ 1 +
     \alpha\lambda(x-\mu) \right]^{-\frac{1}{\alpha}} \right\}
\\%
\label{eqn:gev_distribution}
\end{eqnarray}

The parameters $\mu$, $\lambda$, and $\alpha$ are location, scale, and
shape parameters, respectively, with $-\infty < \mu < \infty$, $0 <
\lambda < \infty$, and $-\infty < \alpha < \infty$.

The Type II (Fr\'{e}chet) distribution corresponds to $\alpha > 0$,
and the Type III (Weibull) distribution corresponds to $\alpha < 0$.
The Type I (Gumbel) distribution arises in the limit $\alpha
\rightarrow 0$. At values $\alpha \simeq 0$, Easel's GEV functions
revert to the Gumbel limit case, as opposed to dividing by zero and
failing.

Technically the GEV is only defined for values of $x$ such that $1 +
\alpha \lambda (x - \mu) > 0$. However, Easel's functions return
sensible values outside this domain, such as 0 for nonexistent
densities.

Generalized extreme value densities for $\mu = 0$ and $\lambda = 1$
are shown below (left) for three settings of $\alpha$; $\alpha = 0$
(Gumbel), $\alpha = 0.1$ (Fr\'{e}chet), and $\alpha = -0.1$
(Weibull). The figure on the right shows the log densities, which more
clearly show how, relative to the exponential right tail of the
Gumbel, the Fr\'{e}chet's tail is longer, and the Weibull's tail is
shorter.

\centerline{
\begin{minipage}{3in}
\includegraphics[width=2.8in]{figures/gev_density}
\end{minipage}
\begin{minipage}{3in}
\includegraphics[width=2.8in]{figures/gev_logdensity}
\end{minipage}
}

For more details, see the excellent description in \citep{Coles01}.
Easel's $\{ \mu, \lambda, \alpha \}$ notation differs from the $\{
\mu, \sigma, \xi \}$ parameterization used by Coles. Use $\lambda =
\frac{1}{\sigma}$ and $\alpha = \xi$ to translate.

\subsection{Fitting GEV distributions to observed data}

Easel fits GEVs by maximum likelihood estimation by numerically
optimizing the log likelihood function, using first derivative
information and conjugate gradient descent.  See the \eslmod{gumbel}
chapter for a more general introduction to maximum likelihood fitting.

\subsubsection{Maximum likelihood estimation, complete data}

The function \ccode{esl\_gev\_FitComplete()} uses gradient information
to find parameters that optimize the likelihood function, using the
conjugate gradient descent code in the \eslmod{minimizer} module.

Given $n$ samples $x_1..x_n$, we want to estimate maximum likelihood
parameter estimates $\{ \hat{\mu}, \hat{\lambda}, \hat{\alpha} \}$
that maximize the log likelihood:

\begin{equation}
\log L(\lambda, \mu, \alpha) = n \log \lambda
       - \frac{\alpha+1}{\alpha}
           \sum_{i=1}^{n} \log\left[1+ \alpha\lambda(x_i - \mu) \right]
       - \sum_{i=1}^{n} \left[ 1 + \alpha\lambda (x_i - \mu) \right]^{\frac{1}{\alpha}}
\label{eqn:gev_logL}
\end{equation}

The $\left[ 1 + \alpha\lambda (x_i - \mu) \right]^{\frac{1}{\alpha}}$
term can be rewritten in a more conveniently differentiable form as
$\exp \left\{ \frac{1}{\alpha} \log \left[ 1 + \alpha\lambda (x_i - \mu)
\right] \right\}$.

Since the $\lambda$ parameter is constrained to $\lambda > 0$ but the
numerical optimizer expects unconstrained parameters, we use a change
of variables $\lambda = e^w$ and optimize an unconstrained value $w$.

The gradient of the log likelihood with respect to $\mu$, $w$, and
$\alpha$ is:

%% xref: STL9/118-120
\begin{eqnarray}
\frac{\partial \log L}{\partial \mu} & = &
  \sum_{i=1}^n \frac{\lambda (\alpha+1)}{1+\alpha\lambda(x_i-\mu)}
 -\sum_{i=1}^n \lambda \exp
    \left\{ -\frac{\alpha+1}{\alpha} \log
          \left[1+\alpha\lambda(x_i-\mu)\right] \right\}
\\%
\label{eqn:gev_mupartial}
\frac{\partial \log L}{\partial w} & = &
  n - \sum_{i=1}^{n} \frac{\lambda (\alpha+1) (x_i - \mu)}
                          {1 + \alpha \lambda (x_i - \mu)}
  + \sum_{i=1}^n \lambda (x_i - \mu)
         \exp \left\{ -\frac{\alpha+1}{\alpha} \log
          \left[1+\alpha\lambda(x_i-\mu)\right] \right\}
\\%
\label{eqn:gev_wpartial}
\frac{\partial \log L}{\partial \alpha} & = &
   \sum_{i=1}^n \left\{
      \begin{array}{l}
      - \frac{\alpha+1}{\alpha} \frac{\lambda(x_i-\mu)}
                                  {1 +\alpha\lambda(x_i-\mu)}\\
      + \frac{1}{\alpha^2} \log \left[ 1 + \alpha\lambda(x_i - \mu) \right]\\
      + \frac{1}{\alpha} \frac{\lambda(x_i-\mu)}
                          {1 +\alpha\lambda(x_i-\mu)}
      e^{-\frac{1}{\alpha} \log\left[ 1 + \alpha\lambda(x_i - \mu) \right]}\\
     -  \frac{1}{\alpha^2} \log \left[ 1 + \alpha\lambda(x_i - \mu) \right]
      e^{-\frac{1}{\alpha} \log\left[ 1 + \alpha\lambda(x_i - \mu)
	 \right]}
     \end{array}
     \right.
\\%
\label{eqn:gev_alphapartial}
\end{eqnarray}

When $|\alpha\lambda(x_i - \mu)|$ approaches $0$, the GEV approximates
a Gumbel distribution and these equations can be simplified using the
approximation $\log(1+a) \simeq a$.


\documentclass[main.tex]{subfiles}
\begin{document}

\section{Relativistic classical field theory}

\marginpar{Friday\\ 2020-5-8, \\ compiled \\ \today}

We want to build a relativistic field theory starting from a lagrangian density \(\mathscr{L}\).
What conditions should we impose on it?

\begin{enumerate}
    \item The action \(S = \int \dd[4]{x} \mathscr{L}\) must be a real functional, so \(\mathscr{L}\) must be a real function.
    \item The action \(S\) must be adimensional,\footnote{Why? Well, the simplest argument I can think of is that is should have the same dimensionality it has in classical theory. Beyond that, when we write a path integral
    %
    \begin{align}
    K \sim \int \mathcal{D} x e^{- i S}
    \,
    \end{align}
    %
    the action goes into the argument of the exponential, so it must be adimensional.} so the Lagrangian must have the dimensions of a length to the \(-4\), which is equivalent to a mass to the \(4\)th power.
    \item The action \(S\) must be a Lorentz scalar, therefore (since \(\dd[4]{x}\) is a scalar) the Lagrangian must also be a scalar.
    \item We want second-order equations of motion, so we ask that \(\mathscr{L} = \mathscr{L}( \varphi , \partial_{\mu }\varphi )\).
\end{enumerate}

\subsection{Real scalar field}

We consider a real scalar field \(\varphi (x)\). In analogy to classical theory, we choose the Lagrangian
%
\begin{align}
\mathscr{L} = \underbrace{\frac{1}{2} \qty(\partial_{\mu } \varphi ) \qty(\partial^{\mu } \varphi )}_{\text{kinetic term}} - \underbrace{\frac{1}{2} m^2 \varphi^2}_{\text{mass term}}
\,.
\end{align}

This is a \emph{free particle} Lagrangian: it does not contain powers of \(\varphi \) which are higher than two. These higher terms would represent interactions.
In order for our conditions to hold, the dimensions of both \(m\) and \(\varphi \) must be those of a mass.

The Euler-Lagrange equations read:
%
\begin{align}
\qty(\square + m^2) \varphi = 0
\,,
\end{align}
%
which is the Klein-Gordon equation.
As we saw in section \ref{sec:solutions-free-KG-equation}, the solutions to this equation are given by
%
\begin{align}
\varphi (x) =
\frac{1}{(2 \pi )^{3/2}}
\int \frac{ \dd[3]{k}}{\sqrt{2 \omega_{k}}}
\qty(a(k) e^{-ikx} + a^{*}(k) e^{ikx})_{k^{0} = \omega_{k}}
\,.
\end{align}

Let us also express this in the Hamiltonian formulation: the momentum is given by
%
\begin{align}
\pi (x) = \pdv{\mathscr{L}}{\partial^{0} \varphi } = \partial_{0} \varphi
\,,
\end{align}
%
and using it we can write the Hamiltonian density with the usual formula:
%
\begin{align}
\mathscr{H} = \pi \partial_{0} \varphi - \mathscr{L} = \frac{1}{2} \pi^2 + \frac{1}{2} \qty(\nabla \varphi )^2 + \frac{1}{2} m^2 \varphi^2
\,.
\end{align}

Note that this is positive definite: so the Hamiltonian, its integral (\(H = \int \mathscr{H} \dd[3]{x}\)) also is.
We can write down the Hamilton equations and see that they are equivalent to the Lagrange ones: they read
%
\begin{subequations}
\begin{align}
\dot{\varphi}_{t} (\vec{x}) &= \fdv{H}{\pi_{t} (\vec{x})}
 = \pi = \partial_{0} \varphi   \\
\dot{\pi}_{t} &= - \fdv{H}{\varphi_{t}}  \\
&= - \frac{1}{2} \fdv{}{\varphi } \int \pi^2 + \qty(\nabla \varphi)^2 + m^2 \varphi^2 \dd[3]{x}  \\
&= - \fdv{}{\varphi } \int \dd[3]{x} \qty[- \varphi \nabla^2 \varphi + \frac{1}{2} m^2 \varphi ]  \\
&= \nabla^2\varphi  - m^2 \varphi
\,,
\end{align}
\end{subequations}
%
where we used the fact that
%
\begin{subequations}
\begin{align}
\frac{1}{2}\fdv{}{\varphi(x) } \int \qty(\nabla \varphi(y) )^2 \dd[3]{y}
&= \int \dd[3]{y} \fdv{ \nabla \varphi (y) }{\varphi (x) } \cdot \nabla \varphi (y) \\
&= \int \dd[3]{y} \nabla \qty(\fdv{\varphi (y) }{\varphi( x) } ) \cdot\qty(\nabla \varphi (y) )  \\
&= - \int \dd[3]{y} \fdv{\varphi (y) }{\varphi(x) } \nabla^2 \varphi (y)   \\
&= - \int \dd[3]{y} \delta^{(3)} (x- y) \nabla^2 \varphi (y)
= - \nabla^2\varphi (x)
\,.
\end{align}
\end{subequations}

By the KG equation, the result can also be written as \(\partial_{0}^2 \varphi\).

Let us now discuss the \textbf{Nöther currents} associated with the symmetries of this Lagrangian. It does not explicitly depend on space nor time, so it has \textbf{Poincaré invariance}: the associated canonical stress-energy-momentum tensor is given by
%
\begin{align}
\widetilde{T}^{\mu }_{\nu }
= \qty(\partial^{\mu } \varphi ) \qty(\partial_{\nu } \varphi ) - \delta^{\mu }_{\nu }\mathscr{L}
\,.
\end{align}

Note that, in this case, the stress-energy tensor is symmetric (\(\widetilde{T}^{\mu \nu } = \widetilde{T}^{\nu \mu }\)). This is not a general fact, but it can be shown that the canonical stress-energy tensor can be made into a symmetric tensor in general: this is the so-called Belinfante-Rosenfeld stress-energy tensor.

The components of the total momentum are given by integrating \(\widetilde{T}^{0}_{\nu }\) over 3-space: they are
%
\begin{subequations}
\begin{align}
P_{0} &= \int \widetilde{T}^{0}_{0} = \int \dd[3]{x} \qty(\partial_{0}\varphi )^2  - \mathscr{L} = \int \dd[3]{x} \mathscr{H}= H  \\
P_{i} &= \int \widetilde{T}^{0}_{i} = \int \dd[3]{x} \qty(\partial^{0}\varphi) \qty(\partial_{i} \varphi )
\,.
\end{align}
\end{subequations}

\begin{claim}
We can check explicitly that these currents are indeed conserved, that is, that \(\partial_{\mu } \widetilde{T}^{\mu }_{\nu } =0 \) is an identity.
\end{claim}

\begin{proof}
The computation goes as such:
%
\begin{subequations}
\begin{align}
\partial_{\mu } \widetilde{T}^{\mu }_{\nu } &= \partial_{\mu } \qty(\partial^{\mu } \varphi \partial_{\nu } \varphi ) - \partial_{\nu } \mathscr{L}  \\
&= \partial_{\mu } \partial^{\mu } \varphi \partial_{\nu } \varphi
+ \partial^{\mu }\varphi \partial_{\mu } \partial_{\nu } \varphi
- \frac{1}{2} \partial_{\nu } \qty( \partial_{\mu } \varphi \partial^{\mu } \varphi  -  m^2 \varphi^2)  \\
&= \partial_{\mu } \partial^{\mu } \varphi \partial_{\nu } \varphi
+ \partial^{\mu }\varphi \partial_{\mu } \partial_{\nu } \varphi
- \partial_{\nu } \partial_{\mu } \varphi \partial^{\mu } \varphi
+ m^2 \varphi \partial_{\nu } \varphi
\marginnote{The \(1/2\) goes away since we are differentiating squares.}
\\
&= (\square \varphi + m^2 \varphi ) \partial_{\nu }\varphi  = 0
\,,
\end{align}
\end{subequations}
%
where derivatives are always intended to only act on what's directly in front of them, and where finally we recover the KG equation.
\end{proof}

The Lagrangian is also invariant under \textbf{Lorentz transformations}:
since our field is a Lorentz scalar it will not change under them, therefore the generators \(X\) must be zero.

So, in equation \eqref{eq:conserved-currents-Lorentz} we will have \(\Sigma_{\rho \sigma } = 0\), which means
%
\begin{align}
J^{\mu }_{(\rho \sigma )} = 2 x_{[\rho } \widetilde{T}^{\mu }_{\sigma ]} = L^{\mu }_{\rho \sigma }
\,,
\end{align}
%
The current density associated with the regular angular momentum.
The integral of its \(\mu = 0\) component in \(\dd[3]{x}\) yields the total angular momentum.

\begin{claim}
This is indeed a conserved current: \(\partial_{\mu } J^{\mu }_{\rho \sigma } = 0\).
\end{claim}

\begin{proof}
We take the divergence explicitly:
%
\begin{subequations}
\begin{align}
\partial_{\mu } J^{\mu }_{\rho \sigma } &= \partial_{\mu } \qty(2 x_{[\rho } \widetilde{T}^{\mu }_{\sigma ]})  \\
&= 2 \qty(\partial_{\mu } x_{[\rho } ) \widetilde{T}^{\mu }_{\sigma ]}
+ 2 x_{[\rho } \partial_{\mu } \widetilde{T}^{\mu }_{\sigma ]}   \\
&= 2 \eta_{\mu [\rho } \widetilde{T}^{\mu }_{\sigma ]} = \widetilde{T}_{[\rho \sigma ]} = 0
\,,
\end{align}
\end{subequations}
%
where we have used the fact that the canonical stress-energy tensor for a real scalar field is conserved: \(\partial_{\mu } \widetilde{T}^{\mu }_{\nu } = 0\), and symmetric.
\end{proof}

\subsection{Complex scalar field}

Now, let us consider a complex scalar field, such that in general \(\varphi \neq \varphi^{*}\) and \(\varphi ' (x') = \varphi (x)\) under Poincaré transformations.

Then, we can write our Lagrangian as
%
\begin{align}
\mathscr{L} = \qty(\partial^{\mu } \varphi^{*}) \qty(\partial_{\mu } \varphi )
- m^2 \abs{\varphi }^2
\,,
\end{align}
%
where we dropped the \(1/2\) factor from the real case.
This is equivalent, since Lagrangians are defined up to a multiplicative factor, but there is a reason for it.

The complex field \(\varphi_{\mathbb{C}}\) represents two real degrees of freedom:
%
\begin{align}
\varphi_{\mathbb{C}} (x) = \frac{\varphi_{\mathbb{R}, 1}(1) + i \varphi_{\mathbb{R}, 2}}{\sqrt{2}}
\,,
\end{align}
%
where we included a division by \(\sqrt{2}\) for normalization purposes.

This is what makes us remove the \(1/2\) factor: if we take real fields to be special cases of the complex one, for each one we consider we must divide by \(\sqrt{2}\), and since the Lagrangian is quadratic this yields the global factor.

We can recover the two real DoF by either adding or subtracting  \(\varphi \) and \(\varphi^{*}\).
In terms of the real fields we can rewrite the Lagrangian as
%
\begin{subequations}
\begin{align}
\mathscr{L} &= \qty(\partial_{\mu } \frac{\varphi_1 -i \varphi_2 }{\sqrt{2}})
\qty(\partial^{\mu } \frac{\varphi_1 +i \varphi_2 }{\sqrt{2}})
- m^2 \frac{\varphi_1 -i \varphi_2 }{\sqrt{2}} \frac{\varphi_1 + i \varphi_2 }{\sqrt{2}}  \\
&= \frac{1}{2} \partial_{\mu } \varphi_1 \partial^{\mu } \varphi_1
+ \frac{1}{2} \partial_{\mu } \varphi_2 \partial^{\mu } \varphi_2
- \frac{1}{2} m^2 \varphi_1^2 - \frac{1}{2} m^2 \varphi_2^2  \\
&= \mathscr{L}_{1} + \mathscr{L}_{2}
\,.
\end{align}
\end{subequations}

Therefore, the two scalar degrees of freedom are fully decoupled: each has its own Lagrangian, and there is no interaction between them.

In order to derive the equations of motion we can differentiate with respect to either \(\varphi \) or \(\varphi^{*}\). This yields the Klein-Gordon equation for \(\varphi^{*}\) and \(\varphi \) respectively.

So, both \(\varphi \) and \(\varphi^{*}\) satisfy the KG equation.

We have the general form of the solution in terms of the coefficients \(a(k)\) and \(b^{*}(k)\).

We can define the momenta
%
\begin{subequations}
\begin{align}
\pi (x) &= \pdv{\mathscr{L}}{\partial_0 \varphi} = \partial_{0} \varphi^{*}  \\
\pi^{*} (x) &= \pdv{\mathscr{L}}{\partial_0 \varphi^{*}} = \partial_{0} \varphi
\,.
\end{align}
\end{subequations}

In order to fully describe the field, we need both the pair \(\varphi, \pi  \) and \(\varphi^{*}, \pi^{*}\).
The Hamiltonian density is defined as usual: it is
%
\begin{align}
\mathscr{H} = \pi^{* } \pi + \qty(\nabla \varphi )^{*} \cdot \qty(\nabla \varphi ) + m^2\varphi^{*} \varphi \geq 0
\,.
\end{align}

\begin{claim}
The Hamilton equations read
%
\begin{subequations}
\begin{align}
\dot{\varphi}^{*} &= \fdv{H}{\pi^{*}}
= \pi = \partial_0 \varphi^{*} \\
\dot{\pi}^{*} &= - \fdv{H}{\varphi^{*}}
= \nabla^2 \varphi  -m^2 \varphi
\,,
\end{align}
\end{subequations}
%
and their conjugate.
\end{claim}

\todo[inline]{TODO: derive Poincaré currents, I suspect they look very similar to the real case.}

Beyond Poincaré invariance, this Lagrangian has an additional internal symmetry: the \(U(1)\) symmetry \(\varphi \to \varphi e^{i \alpha }\).

For this symmetry, we have
%
\begin{subequations}
\begin{align}
\delta x^{\mu } &= 0   \\
\delta \varphi &= i \alpha \varphi
\,,
\end{align}
\end{subequations}
%
so the generators \(Y\) are zero, while
%
\begin{align}
X_{\varphi } = i \varphi
\qquad \text{and} \qquad
X_{\varphi^{*}} = -i \varphi^{*}
\,,
\end{align}
%
so our conserved current is
%
\begin{subequations}
\begin{align}
J^{\mu } &= \pdv{\mathscr{L}}{\partial_{\mu} \varphi} X_{\varphi } + \pdv{\mathscr{L}}{\partial_{\mu} \varphi^{*}} X_{\varphi^{*}}  \\
&= i \qty(\partial^{\mu } \varphi^{*}) \varphi
- i \qty(\partial^{\mu} \varphi ) \varphi^{*}  \\
&= i \qty(\varphi \partial^{\mu} \varphi^{*}- \varphi^{*} \partial^{\mu } \varphi )
\,.
\end{align}
\end{subequations}

\begin{claim}
This is indeed conserved.
\end{claim}

\begin{proof}
The computation reads:
%
\begin{subequations}
\begin{align}
\partial_{\mu }J^{\mu } &\propto
\partial_{\mu } \qty(\varphi^{*} \partial^{\mu } \varphi
- \varphi \partial^{\mu } \varphi^{*})  \\
&= \partial_{\mu } \varphi^{*} \partial^{\mu } \varphi
+ \varphi^{*} \square \varphi
- \partial_{\mu } \varphi^{*} \partial^{\mu } \varphi
- \varphi \square \varphi^{*}  \\
&= \varphi^{*} \square \varphi
- \varphi \square \varphi^{*}   \\
&= \varphi^{*} m^2 \varphi - \varphi m^2 \varphi^{* } = 0
\,.
\end{align}
\end{subequations}
\end{proof}

We will identify this with leptonic or hadronic number conservation: it will not represent the probability of finding a particle anymore, as it did for the KG equation.

\begin{claim}
The Hamiltonian and total momentum for the real scalar field can be expressed in terms of the coefficients \(a(k)\) as:
%
\begin{subequations}
\begin{align}
H &=  \frac{1}{2} \int \dd[3]{k} \omega_{k}  \qty(a^{*}a + a a^{*})\\
&= \int \dd[3]{k} \omega_{k} a^{*} a
\,,
\end{align}
\end{subequations}
%
and
%
\begin{subequations}
\begin{align}
P^{i} &= \frac{1}{2} \int \dd[3]{k} k^{i}  \qty(a^{*}a + a a^{*})\\
&= \int \dd[3]{k} k^{i} a^{*} a(k)
\,.
\end{align}
\end{subequations}
\end{claim}

\begin{claim}
The total charge for the complex scalar field associated with the \(U(1)\) symmetry is
%
\begin{align}
Q = q\int \dd[3]{k} \qty(a^{*}a - bb^{*})
= q\int \dd[3]{k} \qty(a^{*}a - b^{*}b)
\,,
\end{align}
%
so the particle with negative energy has the opposite charge as the one with positive energy.
\end{claim}

\begin{claim}
A Lagrangian in the form
%
\begin{subequations}
\begin{align}
\mathscr{L} &= \mathscr{L}_{1} + \mathscr{L}_{2}  \\
\mathscr{L}_{i} &= \frac{1}{2} \qty(\partial_{\mu } \varphi_{i}) \qty(\partial^{\mu } \varphi_{i}) - \frac{1}{2} m^2 \varphi_{i}^2
\,
\end{align}
\end{subequations}
%
has \(O(2)\) symmetry in the fields \(\varphi_1 \) and \(\varphi_2 \).
\end{claim}

\begin{claim}
Consider the Lagrangian
%
\begin{subequations}
\begin{align}
\mathscr{L} &= \qty(\partial_{\mu } \phi )^\dag \qty(\partial^{\mu } \phi ) - m^2 \phi ^\dag \phi  \\
\phi &= \left[\begin{array}{c}
\varphi  \\
\chi
\end{array}\right]
\,,
\end{align}
\end{subequations}
%
where \(\varphi \) and \(\chi \) are complex fields.
It is symmetric under \(\phi \to U\phi \), where \(U \in U(2)\); and the current which is conserved due to this symmetry reads
%
\begin{align}
J^{\mu }_{\nu } = i \phi ^\dag \sigma_{\nu } \partial^{\mu } \phi - i \phi \sigma_{\nu } \partial^{\mu } \phi ^\dag
\,,
\end{align}
%
where \(\sigma_{\nu } = (\mathbb{1}, \sigma_{i})^{\top}\).
\end{claim}

\end{document}


\documentclass[a4paper,10pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{bm}

\setcounter{section}{2}
\begin{document}
\section{Process Model}

The reaction rates of components A and B are represented by as follows:
\begin{equation}
  r_{\mathrm{A}} = k_{0} \exp\left(\frac{-\Delta E_{\mathrm{A}}}{RT_{\mathrm{R}}}\right),
\end{equation}
\begin{equation}
  r_{\mathrm{B}} = k_{1} \exp\left(\frac{-\Delta E_{\mathrm{B}}}{RT_{\mathrm{R}}}\right),
\end{equation}
where $T_{\mathrm{R}}$ denotes reactor temperature.
$k_{0}$ and $k_{1}$ denote frequency factors of components A and B, and $\Delta E_{\mathrm{A}}$ and $\Delta E_{\mathrm{B}}$ are activation energies for components A and B, respectively.

\end{document}


%!TEX root = ../../dissertation.tex

\subsection{Noise} % (fold)
\label{sub:noise}

``To generate irregular procedural textures, we need an irregular primitive function, usually called noise" \cite{Ebert2002}. It is a pseudorandom function that breaks the monotony of a pattern and make it look more random.
Perlin Noise is the most known and used noise function. It was created by Ken Perlin, for the movie Tron to generate natural looking textures.

The psedorandom property is important and a true random function like \emph{white noise} would not do the job. If we generate a texture based on white noise the pattern would change every time it is generated and we would like that it stays the same, frame after frame. This is achieved with the use of inputs for this functions so that the same input returns always the same output sequence.

The properties of an ideal \emph{noise} functions are as follows \cite{Ebert2002}:
\begin{itemize}
	\item \emph{noise} is a repeatable pseudorandom function of its inputs
	\item \emph{noise} has a known range, namely, from -1 to 1.
	\item \emph{noise} is band-limited, with a maximum frequency of about 1.
	\item \emph{noise} does not exhibit obvious periodicities or regular patterns. Such pseudorandom functions are always periodic, but the period can be made very long and therefore the periodicity is not conspicuous.
	\item \emph{noise} is \emph{stationary} - that is, its statistical character should be translationally invariant
	\item \emph{noise} is \emph{isotropic} - that is, its statistical character should be rotationally invariant
\end{itemize}

With this noise function, we can generate a sequence of values that are interpolated to produce a coherent noise. With the application of \emph{turbulence} that is composition of several layers of this noise with different frequencies and amplitudes forming a coherent noise. These layers are called \emph{Octaves} and the ratio between amplitude and frequency of the layers can be expressed as a constant known as \emph{persistence} \cite{Kelly2008}. With the result we can create a texture that looks natural and with fractal like structure.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.55\textwidth]{images/Theory/Perlin_Noise/Merge.png}
	\caption{Different noise functions}
	\label{fig:merge}
\end{figure}

For instance, the Figure~\ref{fig:merge} shows the result of the interpolation over six noise functions with different frequencies and different amplitudes. And the sum of all this functions is illustrated in the Figure~\ref{fig:noise} \cite{NoisesELIAS}.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.55\textwidth]{images/Theory/Perlin_Noise/perlin1.png}
	\caption{``You may even imagine that it looks a little like a mountain range."}
	\label{fig:noise}
\end{figure}

Noise can also be used to generate planes. The method used is the same as the 1D problem but we have to generate a lot more data points that are then interpolated as a plane. This results in noisy images that are often used to model clouds, smoke and other textures with similar visual properties as illustrated in Figure~\ref{fig:NTextures}. Another application for this technique is the generation of height maps.

\begin{figure}
        \centering
        %\begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=0.3\textwidth]{images/Theory/Perlin_Noise/gradient_discrete.png}
        %        \label{fig:Ncolors}
        %\end{subfigure}%
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc.
          %(or a blank line to force the subfigure onto a new line)
        %\begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=0.3\textwidth]{images/Theory/Perlin_Noise/gradient_grey.png}
        %        \label{fig:Nblackandwhite}
        %\end{subfigure}
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc.
          %(or a blank line to force the subfigure onto a new line)
        %\begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=0.3\textwidth]{images/Theory/Perlin_Noise/gradient_fire.png}
        %        \label{fig:Nredblack}
        %\end{subfigure}
        \caption{Gradient mapped textures \cite{NoisesGAMES}}
        \label{fig:NTextures}
\end{figure}

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.7\textwidth]{images/Theory/Perlin_Noise/AppletNoName201501191604.png}
    \caption{Objects Placed following a noise function}
    \label{fig:MyNCity}
\end{figure}

Another application for Noise planes is \emph{object placement} on a grid. By creating a noise plane with the same size of the grid, with each cell of the grid corresponding to one pixel of noise, the object placement is done by choosing each object for each cell according to the noise value. Figure~\ref{fig:MyNCity} and
Figure~\ref{fig:NCity} shows two cities which the buildings where placed with the use of a noise plane. In this cases the noise domain was splitted in three intervals, each one corresponds to one type of building (commercial, industrial or residential). After setting the type for one block, the system randomly chooses one from a set of buildings of that type.

\begin{figure}[]
	\centering
	\includegraphics[width=0.73\textwidth]{images/Theory/Perlin_Noise/NoisyCity.jpg}
	\caption{Objects Placed with a noise plane from \cite{NoisesGAMES}}
	\label{fig:NCity}
\end{figure}

% subsubsection noise (end)


\documentclass{amsart}
\begin{document}

\section{Minipage}
% CC-by from https://tex.stackexchange.com/questions/576515/numbering-the-equations-in-latex-with-minipage-and-eqnarray

\begin{eqnarray}
\begin{minipage}{\textwidth}
\begin{split}
P_L_S(f)=\frac{1}{2\sigma^2}\*\Bigg\{\frac{[\sum_{k=1}^N\*(x_k-\bar{x})\cos(2\pi{f}(t_k-\tau))]^2}{\sum_{k=1}^N\*\cos^2(2\pi{f}(t_k-\tau))}\\+\frac{[\sum_{k=1}^N\*(x_k-\bar{x})\sin(2\pi{f}(t_k-\tau))]^2}{\sum_{k=1}^N\*\sin^2(2\pi{f}(t_k-\tau))}\Bigg\}\footnote[2]{To see more about Matlab Plomb equations and described in Equation 4.1 variables, \newline visit Matlab Plomb Documentation www.mathworks.com/help/signal/ref/plomb.html}
\end{split}
\end{minipage}
\end{eqnarray}

\end{document}


%!TEX root = ../User Guide.tex
\chapter{Normalization parameters}
Some definitions of parameters used in normalize CACTUS input and output parameters are given in \Cref{tbl:normalization_parameters}.

\begin{table}[!htbp]
\centering
\caption{Parameters used for non-dimensionalization.}
\label{tbl:normalization_parameters}
\begin{tabular}{p{0.20\textwidth}p{0.70\textwidth}}
\toprule
Variable          & Description \\
\midrule
$\rho$            & Fluid density \\
$U_\infty$        & Freestream fluid flow speed \\
$A_T$             & Turbine reference area. Typically this reference area is chosen to be the projected frontal area of the volume swept by the rotor. \\
$R$               & Turbine reference radius \\
$\omega$          & Turbine rotation rate \\
$U_\textrm{local}$& Fluid flow speed local to an element. \\
$U_\textrm{tip}$  & Turbine tip speed. Defined as $U_\textrm{tip} = \omega R$. \\
$c$               & Element chord length \\
$A_E$             & Element planform area \\
\bottomrule
\end{tabular}
\end{table}

In general, most parameters have been normalized at the machine scale. Unless otherwise noted in the input and output descriptions below, the force, torque, and power coefficients are normalized as:

$$ C_F = \frac{F}{\frac{1}{2} \rho U_\infty^2 A_T} $$
$$ C_T = \frac{T}{\frac{1}{2} \rho U_\infty^2 A_T R} $$
$$ C_P = \frac{P}{\frac{1}{2} \rho U_\infty^3 A_T} $$