\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{afalita6} \pdfinfo{ /Title (linear-algrebra.pdf) /Creator (Cheatography) /Author (afalita6) /Subject (linear algrebra Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{70B8B3} \definecolor{LightBackground}{HTML}{F6FAFA} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{linear algrebra Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{afalita6} via \textcolor{DarkBackground}{\uline{cheatography.com/171839/cs/36095/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}afalita6 \\ \uline{cheatography.com/afalita6} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 14th December, 2022.\\ Updated 14th December, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{3.23505 cm} x{1.74195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Inverse of a matrix}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Triangular or diagonal matrix}} & 1/diagonal entries \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Permuted matrix}} & P transpose \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Other}} & rref ( {[}A eye(){]} ) \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Multiplication of Matrix + angle}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Way 1}} & A*B full multiplication \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Way 2 }} & {[}row A{]}*B \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Way 3}} & {[}col A{]}*B \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{Way 3}} & B11*col(A1)+B21*col(A2) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{Find entry 2,3}} & {[}row A2{]}*{[}columnB3{]} = 1 number \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} {\bf{Rank 1 matrix}} & {[}a11*rowB1; a21*rowB1;a31*rowB1{]} + ... \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{Angle}} & cos(theta) = ({\bf{v}}*{\bf{w}})/(||{\bf{v}}||*||{\bf{w}}||) \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} {\bf{Outer Product}} & {[}column1{]}*{[}1 \# \#{]} find numbers that work \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Transformation and dependency}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Linear Independent}} & Linearly independent if rref(A) -{}-{}-{}-\textgreater{} \#pivots = \#row \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{Linear transformation (x and y given)}} & T (u + v) = T (u) + T (v), T (cu) = cT (u), where c is a number. T is one-to-one if T(u)=0⇒u=0 T is onto if Col(T) = Rm. \tn % Row Count 10 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Projections or Ax=b is inconsistent}} \tn % Row 0 \SetRowColor{LightBackground} formula & A'*A*xhat=A'* \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Step 1}} & rref ( {[}A'*A A'*b{]} ) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Step 2}} & xhat = last column of rref \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{Step 3}} & bhat = A*xhat -{}-\textgreater{} bhat is the vector spaned A closest to v and the projection of the vector onto subspace \tn % Row Count 7 (+ 4) % Row 4 \SetRowColor{LightBackground} {\bf{Step 4}} & be = b - bhat -{}-\textgreater{} be is the vector perpendicular \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} {\bf{Step 4}} & error vector/distance = norm (be) (1/sqr of components of b swuares) \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} {\bf{For regression}} & step 1: f(x) = {[}x{]}{[}b{]}, step 2: A = {[}x.\textasciicircum{}0 ...{]} and y = given, step 3: do LSE and find xhat which will be a,b,c \tn % Row Count 17 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Ax = b}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Echelon form}} & Leading entries in every row are farther to the right than the row above. To do = elimination steps \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{Reduced Echelon form (rref)}} & echelon + columns of leading entries are all 0 except the entry which must be a 1. To do = eliminations steps down to right, then left to top \tn % Row Count 12 (+ 7) % Row 2 \SetRowColor{LightBackground} {\bf{Ax=b with LU}} & L = identity but a21 = -λ1, a31 = -λ2, a32 = -λ3. U = \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Ax = b (A and b specified)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Echelon form}} & Leading entries in every row are farther to the right than the row above. To do = elimination steps \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{Reduced Echelon form (rref)}} & echelon + columns of leading entries are all 0 except the entry which must be a 1. To do = eliminations steps down to right, then left to top \tn % Row Count 12 (+ 7) % Row 2 \SetRowColor{LightBackground} {\bf{Ax=b with LU}} & L = identity but a21 = -λ1, a31 = -λ2, a32 = -λ3. U = echelon. Then do Ly=b - given (solve for y), then Ux=y (solve for x) \tn % Row Count 18 (+ 6) % Row 3 \SetRowColor{white} {\bf{Ax=b with CR}} & tMaybe not full rank. C = columns of A that have a pivot in R. R = rref form. To find x -{}-\textgreater{} using R to find FV, pivots, and special solutions (if b not 0 do rref({[}A b{]})), if one soln is given then add that in gen sol and just do rref(A) \tn % Row Count 29 (+ 11) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Eigenvectors and Eigenvalues}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{v}} & eigenvector \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{λ}} & eigenvalue \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Finding λ}} & 1. Diag or triang = entries of diag. 2. 2x2 do λ = m +- sqrt (m\textasciicircum{}2 - p), where m = (a11+a22)/2, and p = a11*a22 - a12*a21 \tn % Row Count 8 (+ 6) % Row 3 \SetRowColor{white} {\bf{ Finding v}} & rref ( {[}A - λ*eye {]} ) and find FV, pivots, and ss \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{Diagonalization }} & A = P*D*P\textasciicircum{}(-1), where P = {[}eigenvectors{]} , D = diag(λ) \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} {\bf{When can we diagonalize}}* & Only when: square, real λ, and if repeated λ - look rref ( {[}A - λ*eye {]} ) and only 1 pivot. \tn % Row Count 19 (+ 5) % Row 6 \SetRowColor{LightBackground} {\bf{ A = Q*D*Q'}} & Q = special solutions form rref ( {[}A - λ*eye {]} ) for every λ, and then doing norm(q1) for all of them. D = diag(λs) \tn % Row Count 25 (+ 6) % Row 7 \SetRowColor{white} {\bf{ Is λ an eigenvalue}} & Do rref ( {[}A - λ*eye {]} ) and has to be only 1 pivot (linearly dependent) \tn % Row Count 29 (+ 4) % Row 8 \SetRowColor{LightBackground} {\bf{Positive definite}} & λs all positive \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Eigenvectors and Eigenvalues (cont)}} \tn % Row 9 \SetRowColor{LightBackground} {\bf{Semipositive definite}} & λs all positive and at least a 0 \tn % Row Count 2 (+ 2) % Row 10 \SetRowColor{white} {\bf{Indefinite}} & λ at least one is negative \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vector Spaces and Basis}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Subspace}} & If u and v are in W , then u + v are in W , and cu is in W \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{Basis B for V}} & A linearly independent set such that Span (B) = V To show sthg is a basis, show it is linearly independent (rref(A) has NO FV) and spans(no row of 0's). \tn % Row Count 10 (+ 7) % Row 2 \SetRowColor{LightBackground} {\bf{Row(A)}} & Space spanned by the rows of A: Row-reduce A and choose the rows that contain the pivots. Row(A) = R\textasciicircum{}n, dim = rank, Basis of Row = R in A = CR \tn % Row Count 17 (+ 7) % Row 3 \SetRowColor{white} {\bf{Col(A)}} & Space spanned by columns of A: Row-reduce A and choose the columns of A that contain the pivots. Col(A) = R\textasciicircum{}m, dim = rank, Basis of Col = C in A = CR \tn % Row Count 24 (+ 7) % Row 4 \SetRowColor{LightBackground} {\bf{Null(A) / Vector in Null}} & Solutions of Ax = 0. Row-reduce A. Null(A) = R\textasciicircum{}n, dim = n-rank, Basis of Null = rref(A), FV, pivots, special solutions \tn % Row Count 30 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vector Spaces and Basis (cont)}} \tn % Row 5 \SetRowColor{LightBackground} {\bf{LeftNull(A)}} & Solutions of A'x = 0. Row-reduce A'. LeftNull(A) = R\textasciicircum{}m, dim = m-rank, Basis of LeftNull = rref(A'), FV, pivots, special solutions \tn % Row Count 6 (+ 6) % Row 6 \SetRowColor{white} {\bf{Rank(A)}} & number of pivots \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{LightBackground} {\bf{Is v in Null}} & do A*v and it needs to equal to vector 0 \tn % Row Count 9 (+ 2) % Row 8 \SetRowColor{white} {\bf{find v in ColA}} & same vectors as in matrix \tn % Row Count 11 (+ 2) % Row 9 \SetRowColor{LightBackground} {\bf{Is v in col space of B}} & is B*x=v consistent? do rref({[}B v{]}) and see if consistent \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.16956 cm} x{1.04425 cm} p{0.54301 cm} x{1.42018 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Gram-Schmidt steps}} \tn % Row 0 \SetRowColor{LightBackground} A & q1 = A(:,1) & Q = q1 & xhat =(q1'*A(:,2))/(q1'*q1) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} ahat = Q*xhat & q2 = A(:,2) - ahat & Q(:,2) = q2 & Q(:,1) = \seqsplit{1/(q'1*q1)*q1} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Q(:,2) = \seqsplit{1/(q'2*q2)*q2} & Q = {[} Q(:,1) Q(:,2) {]} & R = Q'*A & if 3x3 keep going \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Orthogonality}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{ v and u are othogonal}} & if {\bf{v}}*{\bf{u}} = 0 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{W⊥: }} & Set of v which are orthogonal to every w in W. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Orthogonal projection:}} & If \{u1 · · · uk \} is a basis for W , then orthogonal projection of y on W is: \seqsplit{yˆ=(y·u1/u1*u1)+···+(y·u1/uk*uk)}, and y − yˆ is orthogonal to yˆ, shortest distance btw y and W is ||y−yˆ|| \tn % Row Count 13 (+ 9) % Row 3 \SetRowColor{white} {\bf{Basis of W⊥: }} & basis of Null(Mw) \tn % Row Count 15 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Equalities between basis}} & (RowA)' = NullA and vice versa. (ColA)'=LeftNullA and vice versa \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}