octave:1> size = 12
size =  12

octave:2> I = eye(size)
I =

Diagonal Matrix

   1   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   1   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   1   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   1   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   1   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   1   0
   0   0   0   0   0   0   0   0   0   0   0   1

octave:3> A = [I(12,:) ; I(1:11,:)] % downshift permutation
A =

   0   0   0   0   0   0   0   0   0   0   0   1
   1   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   1   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   1   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   1   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   1   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   1   0

octave:4> Z = zeros(size, size);

octave:5> G = [Z, A; A', Z];

octave:6> eig(G)
ans =

  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1

octave:7> eig([Z, A*A; (A*A)', Z])
ans =

  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1

octave:8> eig([Z, A*A*A; (A*A*A)', Z])
ans =

  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1

octave:9> eig([Z, eye(12); eye(12)', Z])
ans =

  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
  -1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1
   1

Comments Off on Bipartite Graph Formulation of Circulant Matrix

Screen Shot 2015-11-01 at 8.49.58 PM

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}

\begin{document}

\begin{frame}{A New System}
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=0.7cm]
    \tikzstyle{box1} = [rectangle, thick, text centered ,
    text width=1.5cm, minimum height=.7cm,
    top color=white, bottom color=blue!30, draw=blue!40]

    \tikzstyle{box2} = [rectangle, thick, text centered ,
    text width=1.5cm, minimum height=.7cm,
    top color=white, bottom color=red!30, draw=red!40]

    \tikzstyle{box3} = [rectangle, thick, text centered ,
    text width=1.5cm, minimum height=.7cm,
    top color=white, bottom color=green!30, draw=green!40]

    \tikzstyle{box4} = [rectangle, thick, text centered ,
    text width=1.5cm, minimum height=.7cm,
    top color=white, bottom color=cyan!30, draw=cyan!40]

    \coordinate (A) at (-3cm, 0cm);
    \coordinate (B) at ( 0cm, 0cm);
    \coordinate (C) at ( 3cm, 0cm);

    \node [box1] (A1) at (A) {Team1}; 
    \node [box1] (B1) at (B) {Team4};
    \node [box1] (C1) at (C) {Team8};

    \node [box2] (A2) [below of=A1] {Team2};
    \node [box2] (B2) [below of=B1] {Team5};
    \node [box2] (C2) [below of=C1] {Team9};

    \node [box3] (A3) [below of=A2] {Team3};
    \node [box3] (B3) [below of=B2] {Team6};
    \node [box3] (C3) [below of=C2] {Team10};

    \node [box4] (B4) [below of=B3] {Team7};
    
    \node [above of=A1] {A};
    \node [above of=B1] {B};
    \node [above of=C1] {C};
\end{tikzpicture}
\end{figure}

\begin{figure}
\begin{tikzpicture}[node distance=1.8cm]
    \tikzstyle{box1} = [rectangle, thick, text centered ,
    text width=1cm, minimum height=.7cm, rounded corners,
    top color=white, bottom color=blue!30, draw=blue!40]

    \tikzstyle{line} = [thick, draw=black]

    \coordinate (O) at (0cm, 0cm);

    \node [box1] (A1) at (O) {\small A1};
    \node [box1] (B1) [right of=A1] {\small B1};
    \node [box1] (C1) [right of=B1] {\small C1};
    \node [box1] (W1) [right of=C1] {\small W1};
    \node [box1] (W2) [right of=W1] {\small W2};

    \path [line] (A1.north) |- ++(18mm, 5mm) coordinate [pos=.75] (m-1-2) -| (B1.north);

    \path [line] (W1.north) |- ++(10mm, 5mm) coordinate (m-4-5) -| (W2.north);

    \path [line] (C1.north) |- ++(15mm, 10mm) coordinate (m-3-4) -| (m-4-5);

    \path [line] (m-1-2) |- ++(20mm, 10mm) coordinate (m-final) -| (m-3-4);

    \node [below] at (m-1-2) {\small Game 1};
    \node [below] at (m-3-4) {\small Game 2};
    \node [below] at (m-4-5) {\small Game 3};
    \node [above] at (m-final) {\small Korean Series};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
Comments Off on Baseball Elimination Figure

Screen Shot 2015-11-01 at 8.41.20 PM

%\documentclass{standalone}
\documentclass{article}
\usepackage{booktabs}
\newcommand{\ramuno}{\ensuremath{\iota}}

\begin{document}
\begin{table}[h]
  \centering
  \begin{tabular}{l|llll}
    \toprule
    \multicolumn{1}{c|}{order} &
    \multicolumn{1}{c}{$+1$} &
    \multicolumn{1}{c}{$-1$} &
    \multicolumn{1}{c}{$+\ramuno$} &
    \multicolumn{1}{c}{$-\ramuno$} \\
    \midrule
    $4m$   & $m+1$ & $m$   & $m$   & $m-1$ \\
    $4m+1$ & $m+1$ & $m$   & $m$   & $m$   \\
    $4m+2$ & $m+1$ & $m+1$ & $m$   & $m$   \\
    $4m+3$ & $m+1$ & $m+1$ & $m+1$ & $m$   \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}
Comments Off on Booktabs + Multicolumn
% A
>> A = [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];

>> B = A;

>> C = [-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];

>> D = [-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];

>> [eig(A), eig(B), eig(C), eig(D)]
ans =

  -3.00000  -3.00000  -3.23607  -3.23607
   2.00000   2.00000  -3.23607  -3.23607
   2.00000   2.00000  -1.00000  -1.00000
   2.00000   2.00000   1.23607   1.23607
   2.00000   2.00000   1.23607   1.23607

>> [eig(A^2), eig(B^2), eig(C^2), eig(D^2)]
ans =

    4.00000    4.00000    1.00000    1.00000
    4.00000    4.00000    1.52786    1.52786
    4.00000    4.00000    1.52786    1.52786
    4.00000    4.00000   10.47214   10.47214
    9.00000    9.00000   10.47214   10.47214

>> eig(A^2 + B^2 + C^2+ D^2)
ans =

   20
   20
   20
   20
   20


Comments Off on Williamson Matrix
% test matrix
>> A = [1 2 3 4 5;
 6 7 8 9 10;
 11 12 13 14 15; 
 16 17 18 19 20;
 21 22 23 24 25]

A =

    1    2    3    4    5
    6    7    8    9   10
   11   12   13   14   15
   16   17   18   19   20
   21   22   23   24   25

% downshift matrix
>> D = [0 0 0 0 1; 1 0 0 0 0; 0 1 0 0 0; 0 0 1 0 0; 0 0 0 1 0]
D =

   0   0   0   0   1
   1   0   0   0   0
   0   1   0   0   0
   0   0   1   0   0
   0   0   0   1   0

% downshift test
>> D*A
ans =

   21   22   23   24   25
    1    2    3    4    5
    6    7    8    9   10
   11   12   13   14   15
   16   17   18   19   20

% downshift twice
>>  D*D*A
ans =

   16   17   18   19   20
   21   22   23   24   25
    1    2    3    4    5
    6    7    8    9   10
   11   12   13   14   15

% the trace of downshift is merely upshift
>>  D'
ans =

   0   1   0   0   0
   0   0   1   0   0
   0   0   0   1   0
   0   0   0   0   1
   1   0   0   0   0

% which can be verified as follows:
>> A, D'*A
A =

    1    2    3    4    5
    6    7    8    9   10
   11   12   13   14   15
   16   17   18   19   20
   21   22   23   24   25

ans =

    6    7    8    9   10
   11   12   13   14   15
   16   17   18   19   20
   21   22   23   24   25
    1    2    3    4    5

% putting the input matrix to the left of the downshift matrix.
% then it became a left-shift operation.
>> A*D
ans =

    2    3    4    5    1
    7    8    9   10    6
   12   13   14   15   11
   17   18   19   20   16
   22   23   24   25   21

%% Combining together, D'*A*D is down-and-left shift.
>> D'*A*D
A =

    1    2    3    4    5
    6    7    8    9   10
   11   12   13   14   15
   16   17   18   19   20
   21   22   23   24   25

ans =

    7    8    9   10    6
   12   13   14   15   11
   17   18   19   20   16
   22   23   24   25   21
    2    3    4    5    1
Comments Off on Downshift and Upshift Matrix
% positive part
>> P=[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1;
1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0; 
1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1; 
1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1; 
1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1; 
1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0; 
1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0; 
1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0; 
1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1; 
1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0; 
1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1]; 

% negative part
>> N = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0;
0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1;
0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0;
0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0;
0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0;
0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1;
0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1;
0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1;
0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0;
0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1;
0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0];

% zero matrix
>> Z = zeros(size(N)(1));

% an signed adjacency matrix of a complete bipartite graph
>> H = [Z, P-N; P'-N', Z];

% eigenvalues of a signed adjacency matrix
>> eig(H)
ans =

  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
  -3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641
   3.4641

% check that it's a sqrt(12)
>> 3.4641^2
ans =  12.000

% the leading principal sub-matrix of size 12
>> A12 = eig(H(1:12, 1:12)), size(A12)
A12 =

   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0

ans =

   12    1

% the leading principal sub-matrix of size 13
>> A13 = eig(H(1:13, 1:13)), size(A13)
A13 =

  -3.46410
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   0.00000
   3.46410

ans =

   13    1

% the leading principal sub-matrix of size 14
>> A14 = eig(H(1:14, 1:14)), size(A14)
A14 =

  -3.4641e+00
  -3.4641e+00
  -2.2869e-16
  -5.1835e-17
  -3.1072e-32
  -9.8437e-33
  -9.1270e-34
  -1.6678e-48
   6.7204e-34
   2.6380e-33
   5.5511e-17
   1.0011e-16
   3.4641e+00
   3.4641e+00

ans =

   14    1

% the leading principal sub-matrix of size 15
>> A15 = eig(H(1:15, 1:15)), size(A15)
A15 =

  -3.4641e+00
  -3.4641e+00
  -3.4641e+00
  -1.2569e-16
  -5.2487e-17
  -2.7846e-17
   8.3967e-19
   2.9178e-17
   1.3011e-16
   2.6577e-16
   6.1994e-16
   7.9764e-16
   3.4641e+00
   3.4641e+00
   3.4641e+00

ans =

   15    1

% the leading principal sub-matrix of size 16
>> A16 = eig(H(1:16, 1:16)), size(A16)
A16 =

  -3.4641e+00
  -3.4641e+00
  -3.4641e+00
  -3.4641e+00
  -4.8088e-16
  -3.2142e-16
  -1.4036e-16
   1.4234e-17
   1.1284e-16
   2.6229e-16
   4.1426e-16
   4.6066e-16
   3.4641e+00
   3.4641e+00
   3.4641e+00
   3.4641e+00

ans =

   16    1
Comments Off on Lifts, eigenvalues and Hadamard matrices
#!/usr/bin/env python

class Fibo:
	"Class-based Fibonacci recursion"
	def __init__(self, n):
		if n == 1:
			self.value = 1
		elif n == 2:
			self.value = 1
		else:
			A = Fibo(n-1)
			B = Fibo(n-2)
			self.value = A.value + B.value
	def __repr__(self):
		return str(self.value)

if __name__ == "__main__":
	print Fibo(1)
	print Fibo(2)
	print Fibo(3)
	print Fibo(4)
	print Fibo(5)
	print Fibo(6)
	print Fibo(7)
	print Fibo(8)
	print Fibo(9)
	print Fibo(10)
Comments Off on Fibonacci Recursion implemented by Python class
>> A=[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1;
1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0; 
1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1; 
1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1; 
1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1; 
1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0; 
1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0; 
1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0; 
1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1; 
1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0; 
1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1]; 

>> B = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0;
0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1;
0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0;
0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0;
0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0;
0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1;
0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1;
0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1;
0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0;
0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1;
0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0;]

>> G = [Z A Z B;A' Z B' Z;Z B Z A;B' Z A' Z];

>> eig(G)

ans =

  -12.0000
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -3.4641
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
    3.4641
   12.0000

>> % 3.4641^2 = 12
>> A = [1 1 1 1; 1 1 0 0;1 0 1 0; 1 0 0 1];
>> B = [0 0 0 0; 0 0 1 1;0 1 0 1; 0 1 1 0];

>> (A-B)*(A-B)'

ans =

     4     0     0     0
     0     4     0     0
     0     0     4     0
     0     0     0     4

>> >> G = [Z A Z B;A' Z B' Z;Z B Z A;B' Z A' Z];

>> eig(G)

ans =

   -4.0000
   -2.0000
   -2.0000
   -2.0000
   -2.0000
   -0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000
    2.0000
    2.0000
    2.0000
    2.0000
    4.0000
Comments Off on Spectrum of Hadamard Graphs

doc

\documentclass{article}

\usepackage[papersize={5.2in, 1.6in}, text={5in, 1.4in}]{geometry}

% for choosing the proper font encoding
\usepackage[T1]{fontenc}
% for proper encoding
\usepackage[utf8]{inputenc}
% enhanced font Latin Modern
\usepackage{lmodern}
% multi-language support
\usepackage[english]{babel}
% for inline and display quotations.
\usepackage[autostyle]{csquotes}

\usepackage{doi}
\usepackage[ocgcolorlinks,pdfusetitle]{hyperref}
\usepackage[
  backend=biber,
  style=alphabetic,
  citestyle=alphabetic,
  backref=true]{biblatex}

%%%
\usepackage{filecontents}  
\begin{filecontents}{bib.bib}
@article{black1973,
  author = {Black, Fishcer and Scholes, Myron},
  doi = {10.1086/260062},
  journal = {Journal of political economy},
  number = 3,
  pages = {637--654},
  publisher = {UChicago Press},
  title = {The pricing of options and corporate liabilities},
  volume = 81,
  year = 1973
}
\end{filecontents}

\addbibresource{bib.bib}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
\cite{black1973}.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.

\printbibliography

\end{document}
Comments Off on BibLaTeX + backref + biber + doi

test

\documentclass[10pt]{article}

% for smallper page
\usepackage[papersize={4.2in, 1.4in}, text={4in, 1.3in}]{geometry}
% for fancy math
\usepackage{amsmath}

% rank operator
\DeclareMathOperator*{\rank}{rank}

% Matrix transpose
\newcommand{\trans}[1]{\ensuremath{{#1}^\top}}

% for extra space at the end of abbreviation
\usepackage{xspace}

% positive semi-definite
\newcommand{\psd}{\textsc{psd}\xspace}

% boldface uppercase letters for matrices
\newcommand{\Abf}{\ensuremath{\mathbf A}}
\newcommand{\Bbf}{\ensuremath{\mathbf B}}

% boldface lowercase letters for vectors
\newcommand{\xbf}{\ensuremath{\mathbf x}}

% for math blackboard font
\usepackage{amssymb}
% set of real numbers
\newcommand{\Rbb}{\ensuremath{\mathbb R}}

\usepackage{palatino}
\usepackage[sc]{mathpazo}

\begin{document}
\noindent
For any real symmetric matrcies $\Abf$ such that $\rank(\Abf_{n\times n})=r$,
the following statements are equivalent
and any one of them can serve as the definition of
\emph{positive semi-definite} (\psd) matrices.
\begin{itemize}
  \item $\trans\xbf \Abf\xbf \geq 0$ for any non-zero vector
    $\xbf\in\Rbb^{n\times 1}$.
    \hfill\refstepcounter{equation}\textup{(\theequation)}%
  \item All the $n$ eigenvalues of $\Abf$ are non-negative.
    \hfill\refstepcounter{equation}\textup{(\theequation)}%
  \item $\Abf=\trans\Bbf \Bbf$ for some $\Bbf$ with $\rank(\Bbf)=r$.
    \hfill\refstepcounter{equation}\textup{(\theequation)}%
\end{itemize}

\end{document}
Comments Off on Equation numbering in itemized list