{"text": "\\subsection{How many unique operators are there?}\n\nAn arbitrary operator takes \\(n\\) inputs are returns \\(T\\) or \\(F\\).\n\nWith \\(0\\) inputs there is one posible permutation. For every additional input the number of possible permutations doubles. Therefore there are \\(2^n\\) possible permutations.\n\nFor the operator with one permutation there are two operators. For every additional permutation the number of operator doubles. Therefore there are \\(2^{(2^n)}\\) possible operations.\n\nWith \\(0\\) inputs, we need \\(2\\) different operators to cover all outputs. For \\(1\\) input we need \\(4\\) and for \\(2\\) inputs we need \\(16\\).\n\n\\subsection{We don't need \\(0\\)-ary operators}\n\nThere are two unique \\(0\\)-ary operators. One always returns \\(T\\) and the other always returns \\(F\\). These are already described.\n\n\\subsection{We need one unary operator}\n\nFor the operators with \\(1\\) input we have:\n\n\\begin{itemize}\n\\item one which always returns \\(T\\)\n\\item one which always returns \\(F\\)\n\\item one which always returns the same as the input\n\\item one which returns the opposite of the input\n\\end{itemize}\n\nIt is this last one, negation, shown as \\(\\neg \\) and is of most interest.\n\n\\subsection{We can use a subset of binary operators}\n\nThe full list of binary operators are included below.\n\nOf these, the first two are \\(0\\)-ary operators, and so are not needed. The next four are unary operators, and so are not needed.\n\nThe non-implications can be rewritten using negation.\n\n\\subsection{Brackets replace the need for n-ary operators}\n\nN-ary operators contain \\(3\\) or more inputs.\n\nN-ary operators can be defined in terms of binary operators.\n\nAs an example if we want an operator to return positive if all inputs are true, we can use:\n\n\\((\\theta \\land \\gamma )\\land \\beta \\)\n\n", "meta": {"hexsha": "9aa60dc86885fbff3e630a5430f27287331abc07", "size": 1772, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/logic/propositionalLogic/04-02-operators.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/logic/propositionalLogic/04-02-operators.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/logic/propositionalLogic/04-02-operators.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5217391304, "max_line_length": 182, "alphanum_fraction": 0.7387133183, "num_tokens": 420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9597620539235896, "lm_q2_score": 0.8856314677809303, "lm_q1q2_score": 0.849995476536789}} {"text": "\\section{Function Reference}\n\n\\subsection*{abs($x$)}\n\nReturns the absolute value or vector length of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nX = (x,y,z)\nabs(X)\n\\end{verbatim}\n}\n\n\\noindent\n$\\left(x^2+y^2+z^2\\right)^{1/2}$\n\n\\subsection*{adj($m$)}\n\nReturns the adjunct of matrix $m$.\nAdjunct is equal to determinant times inverse.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\nadj(A) == det(A) inv(A)\n\\end{verbatim}\n}\n\n\\noindent\n$1$\n\n\\subsection*{and($a,b,\\ldots$)}\n\nReturns 1 if all arguments are true (nonzero).\nReturns 0 otherwise.\n\n{\\color{blue}\n\\begin{verbatim}\nand(1=1,2=2)\n\\end{verbatim}\n}\n\n\\noindent\n$1$\n\n\\subsection*{arccos($x$)}\n\nReturns the arc cosine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\narccos(1/2)\n\\end{verbatim}\n}\n\n\\noindent\n$\\tfrac{1}{3}\\pi$\n\n\\subsection*{arccosh($x$)}\n\nReturns the arc hyperbolic cosine of $x$.\n\n\\subsection*{arcsin($x$)}\n\nReturns the arc sine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\narcsin(1/2)\n\\end{verbatim}\n}\n\n\\noindent\n$\\tfrac{1}{6}\\pi$\n\n\\subsection*{arcsinh($x$)}\n\nReturns the arc hyperbolic sine of $x$.\n\n\\subsection*{arctan($y,x$)}\n\nReturns the arc tangent of $y$ over $x$.\nIf $x$ is omitted then $x=1$ is used.\n\n{\\color{blue}\n\\begin{verbatim}\narctan(1,0)\n\\end{verbatim}\n}\n\n\\noindent\n$\\tfrac{1}{2}\\pi$\n\n\\subsection*{arctanh($x$)}\n\nReturns the arc hyperbolic tangent of $x$.\n\n\\subsection*{arg($z$)}\n\nReturns the angle of complex $z$.\n\n{\\color{blue}\n\\begin{verbatim}\narg(2 - 3i)\n\\end{verbatim}\n}\n\n\\noindent\n$\\arctan(-3,2)$\n\n\\subsection*{binding($s$)}\n\nThe result of evaluating a symbol can differ from the symbol's binding.\nFor example, the result may be expanded.\nThe {\\tt binding} function returns the actual binding of a symbol.\n\n{\\color{blue}\n\\begin{verbatim}\np = quote((x + 1)^2)\np\n\\end{verbatim}\n}\n\n\\noindent\n$p=x^2+2x+1$\n\n{\\color{blue}\n\\begin{verbatim}\nbinding(p)\n\\end{verbatim}\n}\n\n\\noindent\n$(x+1)^2$\n\n\\subsection*{ceiling($x$)}\n\nReturns the smallest integer greater than or equal to $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nceiling(1/2)\n\\end{verbatim}\n}\n\n\\noindent\n$1$\n\n\\subsection*{check($x$)}\n\nIf $x$ is true (nonzero) then continue, else stop.\nExpression $x$ can include the relational operators\n\\verb$=$,\n\\verb$==$,\n\\verb$<$,\n\\verb$<=$,\n\\verb$>$,\n\\verb$>=$.\nUse the\n\\verb$not$\nfunction to test for inequality.\n\n{\\color{blue}\n\\begin{verbatim}\nA = 1\nB = 1\ncheck(A=B) -- stop here if A not equal to B\n\\end{verbatim}\n}\n\n\\subsection*{circexp($x$)}\n\nReturns expression $x$ with circular and hyperbolic functions\nconverted to exponentials.\n\n{\\color{blue}\n\\begin{verbatim}\ncircexp(cos(x) + i sin(x))\n\\end{verbatim}\n}\n\n\\noindent\n$\\exp(ix)$\n\n\\subsection*{clear}\n\nClears all symbol definitions.\n\n\\subsection*{clock($z$)}\n\nReturns complex $z$ in polar form with base of negative 1 instead of $e$.\n\n{\\color{blue}\n\\begin{verbatim}\nclock(2 - 3i)\n\\end{verbatim}\n}\n\n\\noindent\n$13^{1/2}\\,(-1)^{\\arctan(-3,2)/\\pi}$\n\n\\subsection*{conj($z$)}\n\nReturns the complex conjugate of $z$.\n\n{\\color{blue}\n\\begin{verbatim}\nconj(2 - 3i)\n\\end{verbatim}\n}\n\n\\noindent\n$2 + 3 i$\n\n\\subsection*{contract($a,i,j$)}\n\nReturns tensor $a$ summed over indices $i$ and $j$.\nIf $i$ and $j$ are omitted then 1 and 2 are used.\nThe expression {\\tt contract(m)} computes the trace of matrix $m$.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\ncontract(A)\n\\end{verbatim}\n}\n\n\\noindent\n$a + d$\n\n\\subsection*{cos($x$)}\n\nReturns the cosine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\ncos(pi/4)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{1}{2^{1/2}}$\n\n\\subsection*{cosh($x$)}\n\nReturns the hyperbolic cosine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\ncircexp(cosh(x))\n\\end{verbatim}\n}\n\n\\noindent\n$\\tfrac{1}{2}\\exp(-x)+\\tfrac{1}{2}\\exp(x)$\n\n\\subsection*{d($f,x$)}\n\nReturns the partial derivative of $f$ with respect to $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nd(x^2,x)\n\\end{verbatim}\n}\n\n\\noindent\n$2x$\n\n\\bigskip\n\\noindent\nArgument $f$ can be a tensor of any rank.\nArgument $x$ can be a vector.\nWhen $x$ is a vector the result is the gradient of $f$.\n\n{\\color{blue}\n\\begin{verbatim}\nF = (f(),g(),h())\nX = (x,y,z)\nd(F,X)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\begin{bmatrix}\n\\operatorname{d}(f(),x) & \\operatorname{d}(f(),y) & \\operatorname{d}(f(),z)\\\\\n\\operatorname{d}(g(),x) & \\operatorname{d}(g(),y) & \\operatorname{d}(g(),z)\\\\\n\\operatorname{d}(h(),x) & \\operatorname{d}(h(),y) & \\operatorname{d}(h(),z)\n\\end{bmatrix}\n$\n\n\\bigskip\n\\noindent\nIt is OK to use {\\tt d} as a variable name.\nIt will not conflict with function {\\tt d}.\n\n\\bigskip\n\\noindent\nIt is OK to redefine {\\tt d} as a different function.\nThe function {\\tt derivative}, a synonym for {\\tt d},\ncan still be used to obtain a partial derivative.\n\n\\subsection*{defint($f,x,a,b$)}\n\nReturns the definite integral of $f$ with respect to $x$\nevaluated from $a$ to $b$.\nThe argument list can be extended for multiple integrals\nas shown in the following example.\n\n{\\color{blue}\n\\begin{verbatim}\nf = (1 + cos(theta)^2) sin(theta)\ndefint(f, theta, 0, pi, phi, 0, 2pi) -- integrate over theta then over phi\n\\end{verbatim}\n}\n\n\\noindent\n$\\tfrac{16}{3}\\pi$\n\n\\subsection*{denominator($x$)}\n\nReturns the denominator of expression $x$.\n\n{\\color{blue}\n\\begin{verbatim}\ndenominator(a/b)\n\\end{verbatim}\n}\n\n\\noindent\n$b$\n\n\\subsection*{det($m$)}\n\nReturns the determinant of matrix $m$.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\ndet(A)\n\\end{verbatim}\n}\n\n\\noindent\n$a d - b c$\n\n\\subsection*{dim($a,n$)}\n\nReturns the dimension of the $n$th index of tensor $a$.\nIndex numbering starts with 1.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((1,2),(3,4),(5,6))\ndim(A,1)\n\\end{verbatim}\n}\n\n\\noindent\n$3$\n\n\\subsection*{do($a,b,\\ldots$)}\n\nEvaluates each argument from left to right.\nReturns the result of the final argument.\n\n{\\color{blue}\n\\begin{verbatim}\ndo(A=1,B=2,A+B)\n\\end{verbatim}\n}\n\n\\noindent\n$3$\n\n\\subsection*{dot($a,b,\\ldots$)}\n\nReturns the dot product of vectors, matrices, and tensors.\nAlso known as the matrix product.\n\n{\\color{blue}\n\\begin{verbatim}\n-- solve for X in AX=B\nA = ((1,2),(3,4))\nB = (5,6)\nX = dot(inv(A),B)\nX\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\begin{bmatrix}-4\\\\ \\tfrac{9}{2}\\end{bmatrix}$\n\n\\subsection*{draw($f,x$)}\n\nDraws a graph of $f(x)$.\nDrawing ranges can be set with {\\tt xrange} and {\\tt yrange}.\n\n{\\color{blue}\n\\begin{verbatim}\nxrange = (0,1)\nyrange = (0,1)\ndraw(x^2,x)\n\\end{verbatim}\n}\n\n\\subsection*{eval($f,x,a$)}\n\nReturns expression $f$ evaluated at $x$ equals $a$.\nThe argument list can be extended for multivariate expressions.\nFor example,\n\\verb$eval(f,x,a,y,b)$\nis equivalent to\n\\verb$eval(eval(f,x,a),y,b)$.\n\n{\\color{blue}\n\\begin{verbatim}\neval(x + y,x,a,y,b)\n\\end{verbatim}\n}\n\n\\noindent\n$a+b$\n\n\\subsection*{exp($x$)}\n\nReturns the exponential of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nexp(i pi)\n\\end{verbatim}\n}\n\n\\noindent\n$-1$\n\n\\subsection*{expcos($z$)}\n\nReturns the cosine of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexpcos(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\tfrac{1}{2}\\exp(iz)+\\tfrac{1}{2}\\exp(-iz)$\n\n\\subsection*{expcosh($z$)}\n\nReturns the hyperbolic cosine of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexpcosh(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\tfrac{1}{2}\\exp(-z)+\\tfrac{1}{2}\\exp(z)$\n\n\\subsection*{expsin($z$)}\n\nReturns the sine of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexpsin(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle -\\tfrac{1}{2}i\\exp(iz)+\\tfrac{1}{2}i\\exp(-iz)$\n\n\\subsection*{expsinh($z$)}\n\nReturns the hyperbolic sine of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexpsinh(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle -\\tfrac{1}{2}\\exp(-z)+\\tfrac{1}{2}\\exp(z)$\n\n\\subsection*{exptan($z$)}\n\nReturns the tangent of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexptan(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{i}{\\exp(2iz)+1}-\\frac{i\\exp(2iz)}{\\exp(2iz)+1}$\n\n\\subsection*{exptanh($z$)}\n\nReturns the hyperbolic tangent of $z$ in exponential form.\n\n{\\color{blue}\n\\begin{verbatim}\nexptanh(z)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle -\\frac{1}{\\exp(2z)+1}+\\frac{\\exp(2z)}{\\exp(2z)+1}$\n\n\\subsection*{factorial($n$)}\n\nReturns the factorial of $n$.\nThe expression {\\tt n!} can also be used.\n\n{\\color{blue}\n\\begin{verbatim}\n20!\n\\end{verbatim}\n}\n\n\\noindent\n$2432902008176640000$\n\n\\subsection*{float($x$)}\n\nReturns expression $x$ with rational numbers and integers converted to\nfloating point values.\nThe symbol {\\tt pi} and the natural number are also converted.\n\n{\\color{blue}\n\\begin{verbatim}\nfloat(212^17)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle 3.52947\\times 10^{39}$\n\n\\subsection*{floor($x$)}\n\nReturns the largest integer less than or equal to $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nfloor(1/2)\n\\end{verbatim}\n}\n\n\\noindent\n$0$\n\n\\subsection*{for($i,j,k,a,b,\\ldots$)}\n\nFor $i$ equals $j$ through $k$ evaluate $a$, $b$, etc.\n\n{\\color{blue}\n\\begin{verbatim}\nfor(k,1,3,A=k,print(A))\n\\end{verbatim}\n}\n\n\\noindent\n$A=1$\\\\\n$A=2$\\\\\n$A=3$\n\n\\bigskip\n\\noindent\nNote: The original value of $i$ is restored after {\\tt for} completes.\nIf symbol {\\tt i} is used for index variable $i$\nthen the imaginary unit is overridden in the scope of {\\tt for}.\n\n\\subsection*{i}\n\nSymbol {\\tt i} is initialized to the imaginary unit $\\sqrt{-1}$.\n\n{\\color{blue}\n\\begin{verbatim}\nexp(i pi)\n\\end{verbatim}\n}\n\n\\noindent\n$-1$\n\n\\bigskip\n\\noindent\nNote: It is OK to clear or redefine {\\tt i} and use the symbol for something else.\n\n\\subsection*{imag($z$)}\n\nReturns the imaginary part of complex $z$.\n\n{\\color{blue}\n\\begin{verbatim}\nimag(2 - 3i)\n\\end{verbatim}\n}\n\n\\noindent\n$-3$\n\n\\subsection*{inner($a,b,\\ldots$)}\n\nReturns the inner product of vectors, matrices, and tensors.\nAlso known as the matrix product.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\nB = (x,y)\ninner(A,B)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\n\\begin{bmatrix}\nax+by\\\\\ncx+dy\n\\end{bmatrix}\n$\n\n\\bigskip\n\\noindent\nNote: {\\tt inner} and {\\tt dot} are the same function.\n\n\\subsection*{integral($f,x$)}\n\nReturns the integral of $f$ with respect to $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nintegral(x^2,x)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\tfrac{1}{3}x^3$\n\n\\subsection*{inv($m$)}\n\nReturns the inverse of matrix $m$.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((1,2),(3,4))\ninv(A)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\n\\begin{bmatrix}\n-2 & 1\\\\\n\\tfrac{3}{2} & -\\tfrac{1}{2}\n\\end{bmatrix}\n$\n\n\\subsection*{j}\n\nSet {\\tt j=sqrt(-1)} to use {\\tt j} for the imaginary unit instead of {\\tt i}.\n\n{\\color{blue}\n\\begin{verbatim}\nj = sqrt(-1)\n1/sqrt(-1)\n\\end{verbatim}\n}\n\n\\noindent\n$-j$\n\n\\subsection*{last}\n\nThe result of the previous calculation is stored in {\\tt last}.\n\n{\\color{blue}\n\\begin{verbatim}\n212^17\n\\end{verbatim}\n}\n\n\\noindent\n$3529471145760275132301897342055866171392$\n\n{\\color{blue}\n\\begin{verbatim}\nlast\n\\end{verbatim}\n}\n\n\\noindent\n$last=3529471145760275132301897342055866171392$\n\n\\bigskip\n\\noindent\nSymbol {\\tt last} is an implied argument when a function has no argument list.\n\n{\\color{blue}\n\\begin{verbatim}\nfloat\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle 3.52947\\times10^{39}$\n\n\\subsection*{log($x$)}\n\nReturns the natural logarithm of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nlog(x^y)\n\\end{verbatim}\n}\n\n\\noindent\n$y\\log(x)$\n\n\\subsection*{mag($z$)}\n\nReturns the magnitude of complex $z$.\nFunction {\\tt mag} treats undefined symbols as real while {\\tt abs} does not.\n\n{\\color{blue}\n\\begin{verbatim}\nmag(x + i y)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle (x^2+y^2)^{1/2}$\n\n\\subsection*{not($x$)}\n\nReturns 0 if $x$ is true (nonzero).\nReturns 1 otherwise.\n\n{\\color{blue}\n\\begin{verbatim}\nnot(1=1)\n\\end{verbatim}\n}\n\n\\noindent\n$0$\n\n\\subsection*{numerator($x$)}\n\nReturns the numerator of expression $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nnumerator(a/b)\n\\end{verbatim}\n}\n\n\\noindent\n$a$\n\n\\subsection*{or($a,b,\\ldots$)}\n\nReturns 1 if at least one argument is true (nonzero).\nReturns 0 otherwise.\n\n{\\color{blue}\n\\begin{verbatim}\nor(1=1,2=2)\n\\end{verbatim}\n}\n\n\\noindent\n$1$\n\n\\subsection*{outer($a,b,\\ldots$)}\n\nReturns the outer product of vectors, matrices, and tensors.\nAlso known as the tensor product.\n\n{\\color{blue}\n\\begin{verbatim}\nA = (a,b,c)\nB = (x,y,z)\nouter(A,B)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\n\\begin{bmatrix}\na x & a y & a z\\\\\nb x & b y & b z\\\\\nc x & c y & c z\n\\end{bmatrix}\n$\n\n\\subsection*{pi}\n\nSymbol for $\\pi$.\n\n{\\color{blue}\n\\begin{verbatim}\nexp(i pi)\n\\end{verbatim}\n}\n\n\\noindent\n$-1$\n\n\\subsection*{polar($z$)}\n\nReturns complex $z$ in polar form.\n\n{\\color{blue}\n\\begin{verbatim}\npolar(x - i y)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle (x^2+y^2)^{1/2}\\exp(i\\arctan(-y,x))$\n\n\\subsection*{power}\n\nUse \\verb$^$ to raise something to a power.\nUse parentheses for negative powers.\n\n{\\color{blue}\n\\begin{verbatim}\nx^(-2)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{1}{x^2}$\n\n\\subsection*{print($a,b,\\ldots$)}\n\nEvaluate expressions and print the results.\nUseful for printing from inside a {\\tt for} loop.\n\n{\\color{blue}\n\\begin{verbatim}\nfor(j,1,3,print(j))\n\\end{verbatim}\n}\n\n\\noindent\n$j=1$\\newline\n$j=2$\\newline\n$j=3$\n\n\\section*{product($i,j,k,f$)}\n\nFor $i$ equals $j$ through $k$ evaluate $f$.\nReturns the product of all $f$.\n\n{\\color{blue}\n\\begin{verbatim}\nproduct(j,1,3,x + j)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle x^3+6x^2+11x+6$\n\n\\bigskip\n\\noindent\nNote: The original value of $i$ is restored after {\\tt product} completes.\nIf symbol {\\tt i} is used for index variable $i$\nthen the imaginary unit is overridden in the scope of {\\tt product}.\n\n\\subsection*{quote($x$)}\n\nReturns expression $x$ without evaluating it first.\n\n{\\color{blue}\n\\begin{verbatim}\nquote((x + 1)^2)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle (x+1)^2$\n\n\\subsection*{rank($a$)}\n\nReturns the number of indices that tensor $a$ has.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\nrank(A)\n\\end{verbatim}\n}\n\n\\noindent\n2\n\n\\subsection*{rationalize($x$)}\n\nReturns expression $x$ with everything over a common denominator.\n\n{\\color{blue}\n\\begin{verbatim}\nrationalize(1/a + 1/b + 1/2)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{2a+ab+2b}{2ab}$\n\n\\bigskip\n\\noindent\nNote:\n\\verb$rationalize$\nreturns an unexpanded expression.\nIf the result is assigned to a symbol, evaluating the symbol will expand the result.\nUse\n\\verb$binding$\nto retrieve the unexpanded expression.\n\n{\\color{blue}\n\\begin{verbatim}\nf = rationalize(1/a + 1/b + 1/2)\nbinding(f)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{2a+ab+2b}{2ab}$\n\n\\subsection*{real($z$)}\n\nReturns the real part of complex $z$.\n\n{\\color{blue}\n\\begin{verbatim}\nreal(2 - 3i)\n\\end{verbatim}\n}\n\n\\noindent\n2\n\n\\subsection*{rect($z$)}\n\nReturns complex $z$ in rectangular form.\n\n{\\color{blue}\n\\begin{verbatim}\nrect(exp(i x))\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\cos(x)+i\\sin(x)$\n\n\\subsection*{run({\\it file})}\n\nRun script {\\it file}.\nUseful for importing function libraries.\n\n{\\color{blue}\n\\begin{verbatim}\nrun(\"Downloads/EVA.txt\")\n\\end{verbatim}\n}\n\n\\noindent\nNote: {\\it file} must be in the Downloads folder due to security requirements for apps distributed on the Mac App Store.\n\n\\subsection*{simplify($x$)}\n\nReturns expression $x$ in a simpler form.\n\n{\\color{blue}\n\\begin{verbatim}\nsimplify(sin(x)^2 + cos(x)^2)\n\\end{verbatim}\n}\n\n\\noindent\n1\n\n\\subsection*{sin($x$)}\n\nReturns the sine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nsin(pi/4)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle \\frac{1}{2^{1/2}}$\n\n\\subsection*{sinh($x$)}\n\nReturns the hyperbolic sine of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\ncircexp(sinh(x))\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle -\\tfrac{1}{2}\\exp(-x)+\\tfrac{1}{2}\\exp(x)$\n\n\\subsection*{sqrt($x$)}\n\nReturns the square root of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nsqrt(10!)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle 720\\; 7^{1/2}$\n\n\\subsection*{stop}\n\nIn a script, it does what it says.\n\n\\subsection*{sum($i,j,k,f$)}\n\nFor $i$ equals $j$ through $k$ evaluate $f$.\nReturns the sum of all $f$.\n\n{\\color{blue}\n\\begin{verbatim}\nsum(j,1,5,x^j)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle x^5+x^4+x^3+x^2+x$\n\n\\bigskip\n\\noindent\nNote: The original value of $i$ is restored after {\\tt sum} completes.\nIf symbol {\\tt i} is used for index variable $i$\nthen the imaginary unit is overridden in the scope of {\\tt sum}.\n\n\\subsection*{tan($x$)}\n\nReturns the tangent of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\nsimplify(tan(x) - sin(x)/cos(x))\n\\end{verbatim}\n}\n\n\\noindent\n0\n\n\\subsection*{tanh($x$)}\n\nReturns the hyperbolic tangent of $x$.\n\n{\\color{blue}\n\\begin{verbatim}\ncircexp(tanh(x))\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle -\\frac{1}{\\exp(2x)+1}+\\frac{\\exp(2x)}{\\exp(2x)+1}$\n\n\\subsection*{test($a,b,c,d,\\ldots$)}\n\nIf argument $a$ is true (nonzero) then $b$ is returned, else if $c$ is true then $d$ is returned, etc.\nIf the number of arguments is odd then the final argument is returned if all else fails.\nExpressions can include the relational operators\n\\verb$=$,\n\\verb$==$,\n\\verb$<$,\n\\verb$<=$,\n\\verb$>$,\n\\verb$>=$.\nUse the\n\\verb$not$\nfunction to test for inequality.\n(The equality operator\n\\verb$==$\nis available for contexts in which\n\\verb$=$\nis the assignment operator.)\n\n{\\color{blue}\n\\begin{verbatim}\nA = 1\nB = 1\ntest(A=B,\"yes\",\"no\")\n\\end{verbatim}\n}\n\n\\noindent\nyes\n\n\\subsection*{trace}\n\nSet {\\tt trace=1} in a script to print the script as it is evaluated.\nUseful for debugging.\n\n{\\color{blue}\n\\begin{verbatim}\ntrace = 1\n\\end{verbatim}\n}\n\n\\noindent\nNote:\nThe\n\\verb$contract$\nfunction is used to obtain the trace of a matrix.\n\n\\subsection*{transpose($a,i,j$)}\n\nReturns the transpose of tensor $a$ with respect to indices $i$ and $j$.\nIf $i$ and $j$ are omitted then 1 and 2 are used.\nHence a matrix can be transposed with a single argument.\n\n{\\color{blue}\n\\begin{verbatim}\nA = ((a,b),(c,d))\ntranspose(A)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\n\\begin{bmatrix}\na & c\\\\\nb & d\n\\end{bmatrix}\n$\n\n\\bigskip\n\\noindent\nNote:\nThe argument list can be extended for multiple transpose operations.\nThe arguments are evaluated from left to right.\nFor example,\n\\verb$transpose(A,1,2,2,3)$\nis equivalent to\n\\verb$transpose(transpose(A,1,2),2,3)$.\n\n\\subsection*{unit($n$)}\n\nReturns an $n$ by $n$ identity matrix.\n\n{\\color{blue}\n\\begin{verbatim}\nunit(3)\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\n\\begin{bmatrix}\n1 & 0 & 0\\\\\n0 & 1 & 0\\\\\n0 & 0 & 1\n\\end{bmatrix}\n$\n\n\\subsection*{zero($i,j,\\ldots$)}\n\nReturns a null tensor with dimensions $i$, $j$, etc.\nUseful for creating a tensor and then setting component values.\n\n{\\color{blue}\n\\begin{verbatim}\nA = zero(3,3)\nfor(k,1,3,A[k,k]=k)\nA\n\\end{verbatim}\n}\n\n\\noindent\n$\\displaystyle\nA=\n\\begin{bmatrix}\n1 & 0 & 0\\\\\n0 & 2 & 0\\\\\n0 & 0 & 3\n\\end{bmatrix}\n$\n", "meta": {"hexsha": "2eb98a62a1e9b6b04f97fcf20db4d03c3363260a", "size": 18366, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/help.tex", "max_stars_repo_name": "DazzlingOkami/eigenmath", "max_stars_repo_head_hexsha": "d46e595598947e21598900aa7321244b89b3a67d", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/help.tex", "max_issues_repo_name": "DazzlingOkami/eigenmath", "max_issues_repo_head_hexsha": "d46e595598947e21598900aa7321244b89b3a67d", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/help.tex", "max_forks_repo_name": "DazzlingOkami/eigenmath", "max_forks_repo_head_hexsha": "d46e595598947e21598900aa7321244b89b3a67d", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.2668329177, "max_line_length": 120, "alphanum_fraction": 0.6751061745, "num_tokens": 6233, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240177362488, "lm_q2_score": 0.9059898140375993, "lm_q1q2_score": 0.8499308043730694}} {"text": "\n\\subsection{Prime numbers and composite numbers}\n\n\\subsubsection{Definition}\n\nA prime number is a number which does not have any divisors other than \\(1\\) and itself.\n\nBy convention we do not refer to \\(0\\) or \\(1\\) as prime numbers.\n\n\\subsubsection{Identifying prime numbers}\n\nDivisors must be smaller than the number. As a result it is easy to identify early prime numbers, as we can try to divide by all preceding numbers.\n\n\\subsubsection{Examples of prime numbers}\n\n\\([2, 3 5, 7, 11, 13,...]\\)\n\n\\subsubsection{Composite numbers}\n\nComposite numbers are numbers that are made up through the multiplication of other numbers.\n\nThey are not prime.\n\n", "meta": {"hexsha": "2b70259f41df131fda1e4db6fdb0898b014c330b", "size": 650, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/logic/primes/01-01-Primes.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/logic/primes/01-01-Primes.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/logic/primes/01-01-Primes.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0833333333, "max_line_length": 147, "alphanum_fraction": 0.7569230769, "num_tokens": 153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9465966747198242, "lm_q2_score": 0.8976952914230971, "lm_q1q2_score": 0.8497553777727472}} {"text": "\n\\subsection{Finite state Markov chains}\n\n\\subsubsection{Transition matrices}\n\nThis shows the probability for moving between discrete states.\n\nWe can show the probability of being in a state by multiplying the vector state by the transition matrix.\n\n\\(Mv\\)\n\n\\subsubsection{Time-homogenous Markov chains}\n\nFor time-homogenous Markov chains the transition matrix is independent of time.\n\nFor these we can calculate the probability of being in any given state in the future:\n\n\\(M^nv\\)\n\nThis becomes independent of v as we tend to infinity. The initial starting state does not matter for long term probabilities.\n\nHow to find steady state probability?\n\n\\(Mv=v\\)\n\nThe eigenvectors! With associated eigenvector \\(1\\). There is only one eigenvector. We can find it by iteratively multiplying any vector by \\(M\\).\n\n", "meta": {"hexsha": "2ae715fd209741036f3be9d1f65ac981e6a875c9", "size": 807, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/probability/stochasticMarkov/02-01-MC_finite.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/probability/stochasticMarkov/02-01-MC_finite.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/probability/stochasticMarkov/02-01-MC_finite.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.8214285714, "max_line_length": 146, "alphanum_fraction": 0.7843866171, "num_tokens": 176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693645535724, "lm_q2_score": 0.8947894639983208, "lm_q1q2_score": 0.849754141684517}} {"text": "\n\\subsection{Herfindahl–Hirschman Index (HHI)}\n\nThe index is the sum of each firm’s market share squared.\n\nFor a monopolist this is \\(1\\), for a completely competitive market it is \\(0\\), or \\(\\dfrac{1}{n}\\).\n\n\\(H=\\sum_{i=1}^ns^2_i\\)\n\nTo normalise this between \\(0\\) and \\(1\\) we can use:\n\n\\(H*=\\dfrac{H-\\dfrac{1}{n}}{1-\\dfrac{1}{n}}\\)\n\n", "meta": {"hexsha": "2106bad0ed48bfebde55fae8bb0bfa49347019a1", "size": 337, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/economics/econometricsAggregate/06-01-HHI.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/economics/econometricsAggregate/06-01-HHI.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/economics/econometricsAggregate/06-01-HHI.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0714285714, "max_line_length": 101, "alphanum_fraction": 0.6439169139, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.957277806109987, "lm_q2_score": 0.8872045899891118, "lm_q1q2_score": 0.8493012634754875}} {"text": "\n\\subsection{Green's theorem}\n\nWe have a curve \\(C\\) on a plane.\n\nInside this is region \\(D\\).\n\nWe have two functions: \\(L(x,y)\\) and \\(M(x,y)\\) defined on the region and curve.\n\n\\(\\oint_C (L dx + M dy)=\\int \\int_D (\\dfrac{\\delta M}{\\delta x}-\\dfrac{\\delta L}{\\delta y})dx dy\\)\n\n\n", "meta": {"hexsha": "e961406395d34b6b5dc65789f3e547dc89cd1e7c", "size": 280, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/multiScalarIntegration/01-05-greenTheorem.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/multiScalarIntegration/01-05-greenTheorem.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/multiScalarIntegration/01-05-greenTheorem.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.5384615385, "max_line_length": 98, "alphanum_fraction": 0.6214285714, "num_tokens": 94, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9658995742876885, "lm_q2_score": 0.8791467675095294, "lm_q1q2_score": 0.8491674884738518}} {"text": "\n\\subsection{Multinomial distribution}\n\nThe mass function for the binomial case is:\n\n\\(f(x)=\\dfrac{n!}{x!(n-x)!}p^k(1-p)^{n-k}\\)\n\n\\subsection{The multinomial distribution}\n\nThis generalises the binomial distribution where there are more than \\(2\\) outcomes.\n\n\\(f(x_1,...,x_n)=\\dfrac{n!}{\\prod_i x_i!}\\prod_i p_i^{x_i}\\)\n\n", "meta": {"hexsha": "246b1e4c2d206ed6dd6fb18ff29ab0dda76ad79a", "size": 321, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/probability/distributionsDiscreteRepeated/01-02-multinomial.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/probability/distributionsDiscreteRepeated/01-02-multinomial.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/probability/distributionsDiscreteRepeated/01-02-multinomial.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.9285714286, "max_line_length": 84, "alphanum_fraction": 0.6947040498, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9658995752693051, "lm_q2_score": 0.8791467611766711, "lm_q1q2_score": 0.8491674832199319}} {"text": "\\section{Page Rank}\n\t\\textbf{Page Rank} is a link analysis algorithm based on the Web graph (pages as nodes and hyper-links as edges), taking the rank value to indicate an importance of a particular page, which is defined recursively and\tdepends on the number of all pages that link to it (in-links).\n\n\t\\subsection{The Simplest Model}\n\tThe page in web can be regard as a node $A$ in a digraph $\\mathcal G=(\\mathcal V,\\mathcal E)$. If the page $A$ have a hyper-link to page $B$, then there is a edge $A\\rightarrow B$ in $\\mathcal E$. For example, the web show in Figure \\eqref{fig:fournodesweb} can be represented by a digraph $\\mathcal G=(\\mathcal V,\\mathcal E)$ with\n\t\\begin{gather*}\n\t\\mathcal{V} =\\{A,B,C,D\\}\\\\\n\t\\mathcal{E} =\\{A\\rightarrow B, A\\rightarrow C,A\\rightarrow D,B\\rightarrow A,\\\\ B\\rightarrow D,C\\rightarrow A,D\\rightarrow B,D\\rightarrow C\\}\n\t\\end{gather*}\n\t\\begin{figure}[h]\n\t\t\\centering\n\t\t\\includegraphics[width=0.7\\linewidth]{fournodesweb}\n\t\t\\caption{A web witch has 4 nodes}\n\t\t\\label{fig:fournodesweb}\n\t\\end{figure}\n\t\n\tSuppose there is a person Jack who is suffering the Internet, and at timing $t$, he is browsing page $A$. When he wants to leave page $A$, he will randomly click a hyper-link in page $A$ and go to browse next page and the possibility of clicking each page is the same. As an example in Figure \\eqref{fig:fournodesweb}, each possibility from $A$ to $B,C,D$ are $\\dfrac 13$. (If the page have no out-links, we can think it have a out-link to itself.) If we do that for each nodes, then we will have a transform matrix $M(\\mathcal G)$. The transform matrix of the \\eqref{fig:fournodesweb} is\n\t\\begin{equation*}\n\t\t\\begin{matrix}\n\t\t to\\backslash from&A&B&C&D\\\\\n\t\tA& &1/2 &1 &\\\\\n\t\tB&1/3 & & &1/2\\\\\n\t\tC&1/3 & & &1/2\\\\\n\t\tD&1/3 &1/2 & &\n\t\t\\end{matrix}\n\t\\end{equation*}\n\ti.e. \n\t\\begin{equation*}\n\t\\mathbf M=\\mathbf M(\\mathcal{G})=\n\t\\begin{pmatrix}\n\t &1/2 &1 &\\\\\n1/3 & & &1/2\\\\\n1/3 & & &1/2\\\\\n1/3 &1/2 & &\n\t\\end{pmatrix}.\n\t\\end{equation*}\n\t\n\tNow, we assume there are a large number of people, and at the timing $t=0$, each page has the same amount of people browsing it, i.e. for every page there are $\\dfrac 1{|\\mathcal V|}$ people browsing it at timing $t=0$. We use a vector $\\mathbf v_0 =(\\dfrac 1{|\\mathcal V|},...,\\dfrac 1{|\\mathcal V|})^T$ to represent the initial state. \n\t\n\tIn the next timing $t=1$, every one randomly clicking a hyper-link in the page which he or she is browsing. Then the distribution of the people at $t=1$ is $$\\mathbf v_1=\\mathbf M\\mathbf v_0.$$ By parity of reasoning, we can obtain the distribution of the people at $t=\\mu$ is $$\\mathbf v_\\mu=\\mathbf M^\\mu\\mathbf v_0.$$\n\t\n\tWe can regard this process is a Markov process, so the convergence of $\\mathbf v_\\mu$ is equivalent to the digraph $\\mathcal G$ is \\textbf{strongly connected}. So we have the following theorem:\n\t\n\t\n\t\\begin{theorem}\n\t\t $\\mathbf v_\\mu$ is convergent $\\Leftrightarrow$ $\\mathcal G$ is strongly connected\n\t\\end{theorem}\n\tIf we get the convergence result $\\mathbf v_\\infty$, the $i$th component $v_{\\infty i}$ measures the importance of the $i$th page. Because the bigger $v_{\\infty i}$ is, the more people will browse this page.\n\tBesides, by the theory of power method, we know if $\\mathbf v_\\mu$ is convergent, then the $\\mathbf v_\\infty$ is the corresponding eigenvector of the max eigenvalue of $\\mathbf M$. \n\t\\subsection{More General Models}\n\tHowever the $\\mathcal G$ of a real Internet web is impossible to be strongly connected, because there is always some pages have no out-links. Besides, if a page only have the out-link to itself, the result $\\|\\mathbf v_\\infty\\|$ may have no use value.\n\t\n\tNow we suppose Jack randomly click a hyper-link in the page with probability $\\alpha$ or randomly input a new URL of a page with probability $1-\\alpha$, so the iteration relation becomes:\n\t\\begin{equation}\\label{alpha}\n\t\\mathbf v_{\\mu+1}=(1-\\alpha)\\mathbf 1 +\\alpha \\mathbf M \\mathbf v_\\mu\n\t\\end{equation}\n\tBecause of $\\|\\mathbf v_0\\|_1=1$ and the sum of each column of $\\mathbf M$ is equal to 1, we can obtain $\\|\\mathbf v_\\mu\\|_1=1$ for any $\\mu$. And the spectral radius of $\\alpha \\mathbf M$ is $$\\rho(\\alpha \\mathbf M)=\\alpha\\rho(\\mathbf M)\\leq\\alpha ||\\mathbf M||_1=\\alpha <1.$$ So the iteration \\eqref{alpha} must be convergent, and $\\mathbf v_\\infty$ satisfy$$ \t\\mathbf v_{\\infty}=(1-\\alpha)\\mathbf 1 +\\alpha \\mathbf M \\mathbf v_\\infty.$$ \n\ti.e.\n\t$$\\mathbf v_\\infty = (1-\\alpha)(1-\\alpha \\mathbf M)^{-1}\\mathbf 1 $$\n", "meta": {"hexsha": "9f97a2d4eae3007f1a430360fcaf69f0cc815539", "size": 4455, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6DL/PageRank.tex", "max_stars_repo_name": "liuzhengqi1996/math452", "max_stars_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "6DL/PageRank.tex", "max_issues_repo_name": "liuzhengqi1996/math452", "max_issues_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6DL/PageRank.tex", "max_forks_repo_name": "liuzhengqi1996/math452", "max_forks_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 74.25, "max_line_length": 589, "alphanum_fraction": 0.7032547699, "num_tokens": 1445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810436809827, "lm_q2_score": 0.8962513662057089, "lm_q1q2_score": 0.8490915547164711}} {"text": "\\section{Physical Interpretations of the Derivative}\r\nAs we've seen, the idea derivative is fundamentally about continuous change.\r\nThis idea makes the derivative very useful for describing physical situations.\r\n\r\n\\begin{example}\r\n\t\tFind the rate of change of the area of a circle with respect to its radius in meters.\r\n\t\tFind the rate of change of the volume of a sphere with respect to its radius in meters.\r\n\t\tWhat are these quantities (with appropriate units) when $r=5\\text{m}$?\r\n\\end{example}\r\n\\begin{answer}\r\n\tStarting with the area of a circle,\r\n\t\\begin{align*}\r\n\t\tA &= \\pi r^2\r\n\t\t\\dd{A}{r} = 2\\pi r.\r\n\t\\end{align*}\r\n\t\r\n\tYou might recognize this as the formula for the circumference of a circle.\\\\\r\n\t\r\n\tStarting with the volume of a sphere,\r\n\t\\begin{align*}\r\n\t\tV &= \\frac{4}{3}\\pi r^3 \\\\\r\n\t\t\\dd{V}{r} &= 4\\pi r^2.\r\n\t\\end{align*}\r\n\t\r\n\tYou might recognize this as the formula for the surface area of a sphere.\\\\\r\n\t\r\n\tWhen $r=5\\text{m}$,\r\n\t\\begin{align*}\r\n\t\t\\dd{A}{r}\\biggr\\rvert_{r=5\\text{m}} &= 2\\pi\\left(5\\text{m}\\right) = 10\\pi\\text{m}. \\\\\r\n\t\t\\dd{V}{r}\\biggr\\rvert_{r=5\\text{m}} &= 4\\pi\\left(5\\text{m}\\right)^2 = 100\\pi\\text{m}^2.\r\n\t\\end{align*}\r\n\\end{answer}\r\n\r\n\\subsection{Displacement, Velocity, and Acceleration}\r\nIf we have an object whose position is determined by a single variable, like time $t$, then we can model the position as a function.\r\n\\begin{equation*}\r\n\ts = f(t).\r\n\\end{equation*}\r\nThe displacement over some interval of length $\\Delta t$, would be\r\n\\begin{equation*}\r\n\t\\Delta s = f(t + \\Delta t) - f(t).\r\n\\end{equation*}\r\nThe average velocity over this interval would be\r\n\\begin{equation*}\r\n\t\\bar{v} = \\frac{f(t + \\Delta t) - f(t)}{\\Delta t}.\r\n\\end{equation*}\r\nAs $\\Delta t$ approaches 0, we see that $\\bar{v}$ is exactly the definition of the derivative of $f$ with respect to $t$: the instantaneous velocity.\r\n\\begin{equation*}\r\n\tv(t) = \\dd{s}{t} = \\lim_{\\Delta t \\to 0}{\\frac{f(t + \\Delta t) - f(t)}{\\Delta t}}.\r\n\\end{equation*}\r\nWe can go through the same steps to derive that instantaneous acceleration is the derivative of instantaneous velocity with respect to $t$.\r\n\\begin{equation*}\r\n\ta(t) = \\dd{v}{t} = \\dd{{}^2s}{t^2} = \\lim_{\\Delta t \\to 0}{\\frac{v(t + \\Delta t) - v(t)}{\\Delta t}}.\r\n\\end{equation*}\r\nAlthough in everyday language we might use the terms speed and velocity interchangeably, speed is defined as the absolute value of velocity, meaning it is a scalar quantity while velocity is a vector quantity.\r\n\\begin{equation*}\r\n\t\\text{Speed} = \\abs{v(t)} = \\biggr\\lvert \\dd{s}{t} \\biggr\\rvert.\r\n\\end{equation*}\r\n\r\n\r\nModeling the motion of free-falling bodies was one of the earliest motivations for discovering calculus.\r\nThrough experiments and applications of physics theory, we know that the height of a falling body when dropped from initial height $h_0$ meters is modeled by\r\n\\begin{equation*}\r\n\ts(t) = h_0 - \\frac{1}{2}gt^2,\r\n\\end{equation*}\r\nwhere $t$ is the time in seconds since the object was released and $g = 9.81m/s^2$ is the acceleration due to gravity near Earth.\r\n\r\n\\begin{example}\r\n\tA ball is dropped from an initial height of 100 meters.\r\n\tHow long does it take for the ball to hit the ground?\r\n\tWhat speed is the ball traveling when it hits the ground?\r\n\\end{example}\r\n\\begin{answer}\r\n\tIn this case, $h_0 = 100\\text{m}$.\r\n\tSo,\r\n\t\\begin{equation*}\r\n\t\ts(t) = 100\\text{m} - \\frac{1}{2}gt^2.\r\n\t\\end{equation*}\r\n\t\r\n\tWe want to solve for $t$ where $s(t)=0$.\r\n\t\\begin{equation*}\r\n\t\tt = \\sqrt{\\frac{200\\text{m}}{g}} \\approx 4.515\\text{s}.\r\n\t\\end{equation*}\r\n\t\r\n\tWe take take the derivative of $s$ with respect to $t$ and then take the absolute value to get the speed.\r\n\t\\begin{align*}\r\n\t\tv(t) &= \\dd{}{t}s(t) = -gt. \\\\\r\n\t\t\\text{Speed}(t) &= \\abs{v(t)} = gt.\r\n\t\\end{align*}\r\n\t\r\n\tPlugging in the time we got when the ball hits the ground,\r\n\t\\begin{equation*}\r\n\t\t\\text{Speed}_{\\text{Ground}} \\approx g(4.515\\text{s}) \\approx 44.294\\text{m/s}.\r\n\t\\end{equation*}\r\n\\end{answer}", "meta": {"hexsha": "fe4b253dcc1898e0a2fc751a5385940120f0dc65", "size": 3925, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/derivatives/physical_interpretations_derivative.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/derivatives/physical_interpretations_derivative.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/derivatives/physical_interpretations_derivative.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 41.3157894737, "max_line_length": 210, "alphanum_fraction": 0.6754140127, "num_tokens": 1266, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012732322216, "lm_q2_score": 0.8976952886860979, "lm_q1q2_score": 0.8490413470138782}} {"text": "\\section{Elementary Equations and Elementary Matrices}\r\n\\begin{definition}\r\n An elementary column operation on an $m\\times n$ matrix $A$ are one of the followings:\\\\\r\n (i) Swap columns $i,j$ with $i\\neq j$.\\\\\r\n (ii) Multiply the entire column $i$ by $\\lambda\\in F\\setminus\\{0\\}$.\\\\\r\n (iii) Add $\\lambda$ times column $i$ to column $j$ where $\\lambda\\in F$.\r\n\\end{definition}\r\nWe can do row operations in a analogous (transposed) way.\r\nSomething remarkable is that these operations are invertible.\r\nInstead of find the inverses one-by-one, we realise these operations via the action of elementary matrices.\r\nLet $E_{ij}$ be the matrix with $1$ on the $i,j$ entry and zero anywhere else, we have:\r\n\\begin{definition}[Elementary Matrices]\r\n The elementary matrices are $T_{ij}=I-E_{ii}-E_{jj}+E_{ij}+E_{ji}$ for $i\\neq j$, $M_{i,\\lambda}=I+(\\lambda-1)E_{ij}$ for $\\lambda\\neq 0$ and $C_{i,j,\\lambda}=I+\\lambda E_{ij}$.\r\n\\end{definition}\r\nThen, we easily see that $T_{ij}$ corresponds to column (row) operation (i), $M_{i,\\lambda}$ to operation (ii) and $C_{i,j,\\lambda}$ to operation (iii) via the operation of multiplying $A$ with the correspondinng matrix from the right (left).\r\n\\begin{example}\r\n $$\\begin{pmatrix}\r\n 1&2\\\\\r\n 3&4\r\n \\end{pmatrix}\\begin{pmatrix}\r\n 0&1\\\\\r\n 1&0\r\n \\end{pmatrix}=\\begin{pmatrix}\r\n 2&1\\\\\r\n 4&3\r\n \\end{pmatrix}$$\r\n\\end{example}\r\n\\begin{proof}[Constructive Proof of Proposition \\ref{eqv_form}]\r\n It suffices to show that we can get from any matrix to\r\n $$\\left( \\begin{array}{c|c}\r\n I_r&0\\\\\r\n \\hline\r\n 0&0\r\n \\end{array} \\right)$$\r\n via elementary column and row operations.\r\n Start with a matrix $A$.\r\n If $A=0$ then we are done.\r\n Otherwise pick $a_{ij}=\\lambda\\neq 0$ and swap rows $i$ and $1$ and then columns $j$ and $1$, after which $\\lambda$ is at position $1,1$.\r\n Then multiply column $1$ by $\\lambda^{-1}$.\r\n So we get $1$ at position $1,1$.\r\n Now we clean up row $1$ and column $1$ via operation (iii) (both row and column).\r\n Afterwards we can perform the same procedure on the submatrix by removing the first row and column.\r\n By induction we can get the desired form at the end.\r\n\\end{proof}\r\nThere are a few variations on these row and column operations.\r\nThe first one is Gauss' pivot algorithm.\r\nIf one use only row operations, then one will reach the ``row echelon form'' (which we will define later) in the following way:\r\nAssume $a_{i1}\\neq 0$ for some $i$.\r\nOtherwise just move on by deleting the first zero columns.\r\nThen swap rows $i$ and $1$ and divide row $1$ by $\\lambda=a_{i1}$ to get $1$ at position $1,1$ and use (iii) to clean up the first column.\r\nAnd one can move on with the same method to the submatrix removing the first row and first column.\r\nDo this repeatedly and at the end we can get a matrix satisfying:\\\\\r\n1. For any $i$ here exists $k(i)\\ge i$ such that $a_{ij}=0$ for any $jk$ such that $a_{k+1,j}=\\lambda\\neq0$.\r\n Otherwise the vector $e_{k+1}$ is not in the span of the column vectors of $A$, contradiction.\r\n So we swap columns $k+1$ and $j$ and then divide column $k+1$ by $\\lambda$.\r\n This gets us $1$ at position $k+1,k+1$.\r\n Then we can clean up the row $k+1$ by this $1$, which completes the induction process.\r\n\\end{proof}\r\nThis immediately provides an algorithm (a quite cost-effective one) for computing the inverse.\r\nAs one can see, this algorithm is analogous to the algorithm of solving a nonsingular linear system.\r\nAlso,\r\n\\begin{proposition}\r\n Any invertible matrix is a product of elementary matrices.\r\n\\end{proposition}\r\n\\begin{proof}\r\n Writing the operations in the preceding lemma as a product of elementary matrices representing the operations gives the inverse of that matrix.\r\n But any invertible matrix is the inverse of its own inverse.\r\n\\end{proof}", "meta": {"hexsha": "95d897124399c08f0fe67d18f19e9813cfb590c9", "size": 4843, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "7/ele.tex", "max_stars_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_stars_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "7/ele.tex", "max_issues_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_issues_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "7/ele.tex", "max_forks_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_forks_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 55.6666666667, "max_line_length": 243, "alphanum_fraction": 0.6855255007, "num_tokens": 1362, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951588871157, "lm_q2_score": 0.908617906830944, "lm_q1q2_score": 0.8490081734209783}} {"text": "\\section{Related Rates}\r\nIn related rates problems, we generally have two related functions and want to know and answer questions about the rate of change of one function given that we know the rate of change of the other. The same problem solving steps as in modeling and optimization apply, but we'll usually be taking derivatives using implicit differentiation with respect to some variable like time.\r\n\r\n\\begin{example}\r\n\tLet $A$ be the area of a square with side length $x$.\r\n\tAssume that $x$ varies with time.\r\n\tHow are $\\dd{A}{t}$ and $\\dd{x}{t}$ related?\r\n\tAt a certain instant, the sides are 3 feet and growing at a rate of 2 feet per minute.\r\n\tHow quickly is the area changing at this instant?\r\n\\end{example}\r\n\\begin{answer}\r\n\tStarting with the area of the square and implicitly differentiating with respect to $t$,\r\n\t\\begin{align*}\r\n\t\tA &= x^2 \\\\\r\n\t\t\\dd{A}{t} = 2x\\dd{x}{t}.\r\n\t\\end{align*}\r\n\t\r\n\tWhen $x=3\\text{ft}$ and $\\dd{x}{t}=3\\text{ft/min}$,\r\n\t\\begin{equation*}\r\n\t\t\\dd{A}{t} = 2(3\\text{ft})(3\\text{ft/min}) = 12\\text{ft$^2$/min}.\r\n\t\\end{equation*}\r\n\\end{answer}\r\n\r\n\\begin{example}\r\n\tThe top of a 13 foot ladder propped against a vertical wall begins falling towards the ground at 12ft/s.\r\n\tWhen the top of the ladder is 5 feet off the ground, how quickly is the bottom of the ladder moving away from the wall?\r\n\tHow is the angle between the ladder and the ground changing?\r\n\\end{example}\r\n\\begin{answer}\r\n\tLet $h$ be the height of the top of the ladder of the ground.\r\n\tThen $\\dd{h}{t} = -12\\text{ft/s}$.\r\n\tLet $b$ the the distance from the base of the ladder to the wall.\r\n\tWe can relate $b$ and $h$ using the Pythagorean Theorem, where the 13-foot long ladder is the hypotenuse.\r\n\t\\begin{equation*}\r\n\t\tb^2 + h^2 = 13^2.\r\n\t\\end{equation*}\r\n\t\r\n\tWe can also use this relationship to see that when $h=5\\text{ft}$, $b=12\\text{ft}$.\r\n\tImplicitly differentiating,\r\n\t\\begin{equation*}\r\n\t\t2b\\dd{b}{t} + 2h\\dd{h}{t} = 0.\r\n\t\\end{equation*}\r\n\t\r\n\tPlugging in what we know and solving for $\\dd{b}{t}$,\r\n\t\\begin{align*}\r\n\t\t2(12\\text{ft})\\dd{b}{t} + 2(5\\text{ft})(-12\\text{ft/s}) &= 0 \\\\\r\n\t\t24\\text{ft}\\dd{b}{t} &= 120\\text{ft$^2$/s} \\\\\r\n\t\t\\dd{b}{t} &= 5\\text{ft/s}.\r\n\t\\end{align*}\r\n\t\r\n\tSo, the base of the ladder is moving away from the wall at a rate of 5ft/s.\r\n\tLet $\\theta$ be the angle between the ladder and the ground.\r\n\tWe can use $\\sin$ to relate $\\theta$ to $b$.\r\n\t\\begin{equation*}\r\n\t\t13\\sin{\\theta} = b.\r\n\t\\end{equation*}\r\n\t\r\n\tImplicitly differentiating,\r\n\t\\begin{equation*}\r\n\t\t13\\text{ft}\\cos{(\\theta)}\\dd{\\theta}{t} = \\dd{b}{t}.\r\n\t\\end{equation*}\r\n\t\r\n\tWhen $\\cos$ is adjacent divided by hypotenuse, so $\\cos{\\theta} = 12/13$.\r\n\tPlugging in what we know and solving for $\\dd{\\theta}{t}$,\r\n\t\\begin{align*}\r\n\t\t13\\text{ft}(12/13)\\dd{\\theta}{t} &= -12\\text{ft/s} \\\\\r\n\t\t\\dd{\\theta}{t} &= -1\\text{/s}.\r\n\t\\end{align*}\r\n\t\r\n\tSo, the angle between the ladder and ground is decreasing at at rate of 1 rad/s.\r\n\\end{answer}\r\n\r\n\\begin{example}\r\n\tGrain is is poured at a rate of 10ft$^3$/min and falls into a cone-shaped pile whose bottom radius is half its altitude.\r\n\tHow fast will the circumference of the base be increasing when the pile is 8 ft tall?\r\n\\end{example}\r\n\\begin{answer}\r\n\tLet $h$ the the altitude of the cone.\r\n\tAt the instant we care about $h=8\\text{ft}$.\r\n\tLet $r$ be the bottom radius of the cone.\r\n\tAt the instant we care about, $r=h/2=4\\text{ft}$.\r\n\tLet $V$ be the volume of the cone.\r\n\tWe know that $\\dd{V}{t}=10\\text{ft$^3$/s}$.\r\n\tWe can relate these three quantites using the formula for the volume of a cone.\r\n\t\\begin{equation*}\r\n\t\tV = \\frac{1}{3}\\pi r^2 h.\r\n\t\\end{equation*}\r\n\t\r\n\tSince we know that $2r = h$, we can simplify to get rid of $h$.\r\n\t\\begin{equation*}\r\n\t\tV = \\frac{2}{3}\\pi r^3\r\n\t\\end{equation*} \r\n\t\r\n\tImplicitly differentiating,\r\n\t\\begin{equation*}\r\n\t\t\\dd{V}{t} = 2\\pi r^2 \\dd{r}{t}.\r\n\t\\end{equation*}\r\n\t\r\n\tWe know the formula for the circumference $C$ of the circular base.\r\n\t\\begin{equation*}\r\n\t\tC = 2\\pi r.\r\n\t\\end{equation*}\r\n\t\r\n\tImplicitly differentiating,\r\n\t\\begin{equation*}\r\n\t\t\\dd{C}{t} = 2\\pi \\dd{r}{t}.\r\n\t\\end{equation*}\r\n\t\r\n\tWe can substitute into our equation involving $\\dd{V}{t}$.\r\n\t\\begin{equation*}\r\n\t\t\\dd{V}{t} = r^2\\dd{C}{t}.\r\n\t\\end{equation*}\r\n\t\r\n\tPlugging in what we know,\r\n\t\\begin{align*}\r\n\t\t10\\text{ft}^3\\text{/s} &= (4\\text{ft})^2\\dd{C}{t} \\\\\r\n\t\t\\dd{C}{t} &= \\frac{5}{8}\\text{ft/s}.\r\n\t\\end{align*}\r\n\\end{answer}\r\n", "meta": {"hexsha": "2417005645413335fef098b54a85b8e695289b87", "size": 4375, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/applications_derivative/related_rates.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/applications_derivative/related_rates.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/applications_derivative/related_rates.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 36.4583333333, "max_line_length": 380, "alphanum_fraction": 0.6521142857, "num_tokens": 1536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951680216529, "lm_q2_score": 0.9086178870347122, "lm_q1q2_score": 0.8490081632232792}} {"text": "\\chapter{Linear Maps, Kernals and Range}\n\n\\begin{definition}\n\tLet $U$ and $V$ be vector spaces over the same field $F$. A mapping $T:U \\rightarrow V$ is linear if \t$ \\forall u_1, u_2 \\in U, \\forall \\lambda \\in F$ \n\t\\begin{center}\n \t\t$T(u_1 + u_2) = T(u_1) + T(u_2)$\\\\ \n \t\t$T(\\lambda u_1) = \\lambda T(u_1)$\n\t\\end{center}\n\t\n\\end{definition}\n\nThe set of all linear mappings from $U \\rightarrow V$ is denoted by $\\mathcal{L}(U,V)$. If $U=V$, then linear mappings are denoted by $\\mathcal{L}(U)$, which is a set of linear mappings from a set onto itself. \\\\ \n\n\\textbf{Examples}\n\\begin{itemize}\n\t\\item $T: \\mathcal{C}[a, b] \\rightarrow \\Re$, $f \\rightarrow \\int_{a}^{b} f(x) dx$. Integration is linear operator since it does not matter whether you add two functions and then integrate or vice versa. Also, we can pull out scalar multiples out of the integrals. \n\t\\item $D: \\mathcal{C}^{\\infty} [a, b] \\rightarrow \\mathcal{C}^{\\infty} [a, b]$, $f \\rightarrow f'$. The derivative of the sum of functions is the same as taking the sum and then derivatves. \\\\\n\\end{itemize}\n\n\\begin{definition}\n\t$T \\in \\mathcal{L}(U, V)$. Then the kernal of $T$ (null space) is defined as : \n\t\\begin{center}\n\t\t$ker(T) := null(T) := \\{u \\in U | Tu = 0\\}$\n\t\\end{center}\n\t\n\\end{definition}\n\n\\begin{proposition}\n\t$ker(T)$ is a subspace of $U$.\n\\end{proposition}\n\n$T$ is injective iff $ker(T) = \\{0\\}$. Means if we take two input points in the input space then they are always mapped to different points in the output space. \nSo 0 is always an element in the kernal since a linear map always maps 0 to 0. Thus the kernal is never empty. The smallest kernal of any vector space is just the 0 vector. \n\n\\begin{definition}\n\tThe range of $T$ (image of $T$) is defined as: \n\t\\begin{center}\n\t\t$range(T) := Image(T) := \\{Tu | u \\in U\\}$\n\t\\end{center}\n\\end{definition}\n\n\\begin{proposition}\n\tThe range is always a subspace of $V$\n\\end{proposition}\n\n$T$ is surjective iff $range(T) = V$\n\n\\begin{definition}\n\t$V' \\subset V$ where $V'$ is any set. The pre-image of $V'$ is defined as: \n\t\\begin{center}\n\t\t$T^{-1} (V') := \\{u \\in U | Tu \\in V'\\}$\n\t\\end{center} \n\\end{definition}\n\n\\begin{proposition}\n\tIf $V' \\subset V$ is a subspace of V, then $T^{-1}(V')$ is a subspace of $U$.\n\\end{proposition}\n\n\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=0.5\\textheight]{ch-3-img-1}\n\t\\caption{Kernal and range of a $T: U \\rightarrow V$}\n\\end{figure}\n\nWe can see in the figure above that a part of $U$ which is mapped to 0 is known as the kernal of tha map $T$. The range lives in $V$ and the kernal lives in $U$. \n\n\\begin{theorem}\n\tLet $V$ be finite dimensionalm $W$ be any vector space and $T \\in \\mathcal{L}(V,W)$. Let $u_1,...,u_n$ be a basis of $ker(T) \\subset V$. Let $w_1,...,w_m$ be a basis of the $range(T) \\subset W$. Then $u_1,...,u_n$, $T^{-1}(w_1),...,T^{-1}(w_m)$ forms a basis of $V$. In particular , $dim(V) = dim(ker(T)) + dim(range(T))$\n\\end{theorem}\n\n\\begin{proof}\n\tDenote $T^{-1}(w_1) := z_1,...,T^{-1}(w_m) := z_m$. If $\\{u_1,...u_n,z_1,...z_m\\}$ for a basis of $V$, then they must span the whole space $V$ and be linearly independent. Let's do each step by step. \\\\\n\tStep 1: Prove that $V \\subset span\\{u_1,...u_n,z_1,...z_m\\}$ \\\\ \n\tLet $v \\in V$, and $Tv \\in range(T)$. Since we know the basis of $range(T)$,\n\t\\begin{align*}\n\t\t\\exists \\lambda_1,...,\\lambda_m: Tv &= \\lambda_1 w_1 + ... + \\lambda_m w_m \\\\\n\t\t\t\t\t\t\t\t\t\t\t&= \\lambda_1 T(z_1) + ... + \\lambda_m T(z_m) \\\\\n\t\t\t\t\t\t\t\t\t\t\t&= T(\\lambda_1 z_1) + ... + T(\\lambda_m z_m)\n\t\\end{align*}\n$ \\implies Tv - T(\\lambda_1z_1 + ... + \\lambda_mz_m) = T(v - (\\lambda_1z_1 + ... + \\lambda_mz_m)) = 0$ \\\\\n$\\implies (v - (\\lambda_1z_1 + ... + \\lambda_mz_m)) \\in kernal(T)$ since this vector is mapped to 0 by the linear mapping. Since we also know the basis of the kernal any vector in the kernal can be written as: \n\\begin{align*}\n(v - (\\lambda_1z_1 + ... + \\lambda_mz_m)) &= \\mu_1 u_1 + ... + \\mu_n u_n \\\\ \nv &= \\lambda_1 z_1 + ... + \\lambda_m z_m + \\mu_1 u_1 + ... + \\mu_n u_n\n\\end{align*}\nStep 2 : Prove that $u_1,...,u_n, z_1,...,z_m$ are linearly independent. \\\\ \nAssume that $\\mu_1 u_1 + ... \\mu_n u_n + \\lambda_1 z_1 + ... + \\lambda_m z_m = 0$ \\\\\nIf these vectors are linearly independent then all the coefficients will simultaneously go to zero. \n\\begin{align*}\n\t\\lambda_1 w_1 + ... + \\lambda_m w_m &= \\lambda_1 T(z_1) + ... + \\lambda_m T(z_m) \\\\\n\t&= \\lambda_1 T(z_1) + ... + \\lambda_m T(z_m) + \\mu_1 T(u_1) + ... + \\mu_n T(u_n) \\\\ \n\t&= T(\\lambda_1 z_1 + ... \\lambda_m z_m + \\mu_1 u_1 + ... + \\mu_n u_n) = T(0) = 0\n\\end{align*}\nWe can add $ \\mu_1 T(u_1) + ... + \\mu_n T(u_n)$ to the expression since it goes to zero by definition of a kernal. Everything inside the operator is zero due to the assumption at the beginning of step 2. \nSince $\\lambda_1 w_1 + ... + \\lambda_m w_m = 0$ and $w_1,...,w_m$ is a basis \n$\\implies \\lambda_1 = ... = \\lambda_m = 0$ \\\\\nNow $\\mu_1 u_1 + ... + \\mu_n u_n = 0$ since we have already proved the other half of the assumption to be zero. Since $u_1,...,u_n$ is the basis of the kernal $\\implies \\mu_1=...\\mu_n=0$.\n\\end{proof}\n\n\\begin{proposition}\n\tLet $T \\in \\mathcal{L}(V, W)$ and $V, W$ be finite dimensional, then the following statements are equivalent.\n\t\\begin{itemize}\n\t\t\\item T is injective\n\t\t\\item T is surjective\n\t\t\\item T is bijective\n\t\\end{itemize} \n\\end{proposition}\n\nThis proposition does not hold in infinite dimensional spaces. \n\n\n\n", "meta": {"hexsha": "0a99a9c39266095e84d97d631f943fd90ba217a1", "size": 5397, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter-3-linearmaps-kernals-range.tex", "max_stars_repo_name": "agupta54/maths-for-ml", "max_stars_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter-3-linearmaps-kernals-range.tex", "max_issues_repo_name": "agupta54/maths-for-ml", "max_issues_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter-3-linearmaps-kernals-range.tex", "max_forks_repo_name": "agupta54/maths-for-ml", "max_forks_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.7610619469, "max_line_length": 322, "alphanum_fraction": 0.6416527701, "num_tokens": 1957, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582554941718, "lm_q2_score": 0.9124361539289197, "lm_q1q2_score": 0.8489837520345143}} {"text": "\\section{Point Mass Distributions}\n\nIf the entire probability is concentrated at a single point $\\alpha$, then that can be expressed in terms of the Kronecker Delta in the discrete case and the Dirac Delta function in the continuous case.\n\n\\subsection{Kronecker Delta $\\delta_{\\alpha}$}\nIn the discrete case:\n\n\\begin{equation}\n\\delta_{\\alpha} = \\left\\{\\begin{array}{l} 1\\mathrm{\\ if\\ }x = \\alpha \\\\ 0\\mathrm{\\ else}\\end{array} \\right.\n\\end{equation}\n\n\\subsection{Dirac Delta Function $\\delta(x-\\alpha)$}\nIn the continuous case:\n\n\\begin{equation}\n\\int_A \\delta(x-\\alpha) \\mathrm{d}x = \\left\\{\\begin{array}{l} 1\\mathrm{\\ if\\ }\\alpha \\in A \\\\ 0\\mathrm{\\ else}\\end{array} \\right.\n\\end{equation}\n\nThe Dirac Delta function is actually a distribution with extremely useful properties that I ought to write up. \n\n\\section{Uniform Distributions}\n\n\\subsection{Discrete Uniform $\\mathrm{Uniform(1,k)}$}\nWith $k>0$ be some integer, the PMF is:\n\n\\begin{equation}\nf(x) = \\left\\{\\begin{array}{l} 1/k \\mathrm{\\ if\\ }x \\in \\{1,...,k\\} \\\\ 0\\mathrm{\\ else}\\end{array} \\right.\n\\end{equation}\n\nThe CDF is:\n\n\\begin{equation}\nF(x)= \\left\\{\\begin{array}{cl} \n0& x < 1\\\\\n\\frac{x}{k}& 1\\leq x \\leq k\\\\\n1& x>k\n\\end{array} \\right.\n\\end{equation}\n\n% continuous uniform\n\\subsection{Continuous Uniform $\\mathrm{Uniform(a,b)}$}\n\nWith $a,b\\in\\mathbb{R}$ and $b>a$, the PDF is:\n\n\\begin{equation}\nf(x) = \\left\\{\\begin{array}{l} 1/(b-a) \\mathrm{\\ if\\ }x \\in [a,b] \\\\ 0\\mathrm{\\ else}\\end{array} \\right.\n\\end{equation}\n\nThe CDF is:\n\n\\begin{equation}\nF(x)= \\left\\{\\begin{array}{cl} \n0& x < a\\\\\n\\frac{x-a}{b-a}& a\\leq x \\leq b\\\\\n1& x>b\n\\end{array} \\right.\n\\end{equation}\n\n\n% bernoulli \n\\section{Bernoulli Processes}\nA Bernoulli process is a number of discrete trials with binary outcome, for example a series of coinflips. This is typically framed in terms of success $X=1$ with probability $p$ and failure $X=0$ with probability $1-p$. The trials are independent from each other. Thinking of the process as a sequence in time, this means that the process is memoryless: the number of successes or time since the last success have no bearing on the future. Thinking about the process as a sequence in space, the successes are independently scattered over a grid like randomly flipped bits in a string of bits. That is, the events are uniformly distributed.\n\n\n\\subsection{Bernoulli $\\mathrm{Bernoulli(p)}$}\nThe PMF of a single binary outcome $X=1$ with probability $p$ and $X=0$ with probability $1-p$. The PMF is:\n\n\\begin{equation}\nf(x) = p^x (1-p)^{1-x} = \\left\\{\\begin{array}{cl} \np& x = 1\\\\\n(1-p)& x=0\n\\end{array} \\right.\n\\end{equation}\n\nFor $x\\in\\{0,1\\}$ and $p\\in[0,1]$.\n\n\n% binomial\n\\subsection{Binomial $\\mathrm{Binomial}(n,p)$}\nThe binomial distribution is the PMF for the number of successes with probability $p$ among $n$ trials. That is, if $X_i \\sim \\mathrm{Bernoulli}(p)$, then $X = \\sum_i^n X_i$ has distribution:\n\n\\begin{equation}\nf(x) = {n \\choose x} p^x (1-p)^{n-x}\n\\end{equation}\n\nIt follows that if $X_1 \\sim \\mathrm{Binomial}(n_1,p)$ and $X_2 \\sim \\mathrm{Binomial}(n_2,p)$, then $X_1 + X_2 \\sim \\mathrm{Binomial}(n_1+n_2,p)$. The binomial distribution can be interpreted of the probability that there will be $x$ successes among $n$ draws with replacement.\n\n\n% geometric distribution\n\\subsection{Geometric $\\mathrm{Geom}(p)$}\nThe PMF for the number of Bernoulli trials with parameter $p\\in(0,1)$ is given by: \n\n\\begin{equation}\nf(x) = p(1-p)^{x-1}\n\\end{equation}\n\nIn the time picture, it models the number of intervals $x$ until the first success occurs, or, equivalently, the number of trials between two successes. In the space picture, it models the distance between successes that are independently scattered on a grid.\n\n\n\n% negative binomial distribution\n\\subsection{Pascal, Negative Binomial $\\mathrm{NB}(r,p)$}\nThe negative binomial distribution with parameters $r$ and $p$ gives the sum of $r$ geometric random variables with parameter $p$. In the time picture, if $X \\sim \\mathrm{NB}(r,p)$, $X$ gives the probability for the number of failures in a sequence of Bernoulli trials until there are $r$ successes. In the space picture, it the probability for the width of the interval of a grid between $r$ successes (not counting the spots taken up by the successes). Its PMF is given by:\n\n\\begin{equation}\nf(x) = {x+r-1\\choose x} p^r (1-p)^x\n\\end{equation} \n\nFor $r=1$, the distribution is the same as the geometric distribution with parameter $p\\rightarrow 1-p$. The negative binomial distribution gives the probability that, when drawing with replacement, it will take $x$ failures until there have been $r$ successes, where each success has probability $p$.\n\n% bernoulli without replacement\n\\section{Bernoulli Processes \tWithout Replacement}\nBernoulli Processes were a sequence of independent trials, which can be thought of as a sequence of samples with replacement. The \"hyper\"- distributions treat the analogous case where samples are not replacemed. \n\n% hypergeometric distribution\n\\subsection{Hypergeometric $\\mathrm{Hypergeom(N,K,n)}$}\nThe hypergeometric distribution gives the probability for the number of successes when drawing $n$ times from a population of $N$, of which $K$ correspond to successes.\n\n\\begin{equation}\nf(k) = \\frac{{K \\choose k}{ N-K \\choose n-k}}{{N \\choose k}}\n\\end{equation} \n\nIt is the analogue to the binomial distribution for sampling without replacement.\n\n% negative hypergeometric distribution\n\\subsection{Negative Hypergeometric $\\mathrm{NH(N,K,n)}$}\nThe negative hypergeometric distribution gives the probability that, when sampling without replacement, it will take $r$ failures until there have been $k$ successes, if the total population is $N$ and the number of elements corresponding to a success is $K$.\n\n\\begin{equation}\nf(k) = \\frac{{k+r-1\\choose k}{N-r-k \\choose K-k}}{{N\\choose K}}\n\\end{equation}\n\nThe negative hypergeometric distribution is the analogue to the negative binomial distribution for sampling without replacement. \n\n\n% poisson processes\n\\section{Poisson Point Processes}\nPoisson point processes are the continuous analogue to Bernoulli processes. Rather than looking at the outcome of a number of binary trials, they look at the number or spacing of independent point events over a continuous interval. In one dimension, Poisson Processes very often model rare events happening over a given time interval. In higher dimensions, the Poisson process can be thought of as independently scattered points in some volume. The process is typically characterized by the parameter $\\Lambda$, called the \\textit{rate} or \\textit{intensity} of the process. It can be written $\\Lambda = \\nu \\lambda$ where $\\nu$ is a Lebesgue measure (assigning a length or volume to a set) and $\\lambda$ is a constant. For a temporal process, $\\nu$ would be the time interval. For a spatial process, $\\nu$ would be a volume. The events have uniform distribution over the measure. This is also called a homogenous Poisson process. \n\n% poisson distribution\n\\subsection{Poisson $\\mathrm{Poisson}(\\Lambda)$}\nThe poisson distribution is the continuous analogue to the Binomial distribution. It measures the number of events for a process with intensity $\\Lambda$.\n\n\\begin{equation}\nf(x) = e^{-\\Lambda}\\frac{\\Lambda^x}{x!}\\ \\ \\mathrm{x\\geq0}\n\\end{equation}\n\nJust like for the Binomial distribution, if $X_1 \\sim \\mathrm{Poisson}(\\Lambda_1)$ and $X_2 \\sim \\mathrm{Poisson}(\\Lambda_2)$, then $X_1 + X_2 \\sim \\mathrm{Poisson}(\\Lambda_1 + \\Lambda_2)$. \n\nThe mean and variance of the poisson distribution are both $\\lambda$. This link means that Poisson distributed data is inherently heteroskedastic. The Poisson distribution can be obtained from the Bernoulli distribution by considering a very large number of trials with a small probability of success in each trial. That is, if $Y \\sim B(n,\\pi)$ then letting $n\\rightarrow \\infty$ with $\\pi \\rightarrow 0$ and $\\mu \\rightarrow n\\pi$ you recover the Poisson distribution. In this sense, the Poisson distribution is an approximation to a Binomial process with rare events with large $n$ and small $\\pi$. \n\n\n\n% exponential distribution\n\\subsection{Exponential $\\mathrm{Exp}(\\lambda)$}\nThe exponential distribution is the continuous analogue to the Geometric distribution. In one dimension, if $X \\sim \\mathrm{Exp}(\\Lambda)$, then $X$ can be interpreted as the distance between two independently scattered points on the real line. In the time picture, that would be the time that elapses between two events, or, equivalently, the time until the next event, where $\\lambda$ is the rate or intensity.\n\n\\begin{equation}\nf(x) = \\lambda e^{-\\lambda}\n\\end{equation}\n\n\n% gamma distribution\n\\subsection{Gamma $\\mathrm{Gamma(\\alpha,\\beta)}$}\nThe Gamma Distribution is the continuous analogue to the negative binomial distribution. For integer $\\alpha$, it gives the probability of the value of the sum of $\\alpha$ exponentially distributed random variables with parameter $\\beta=\\frac{1}{\\lambda}$. That is, if $X_i \\sim Exp(\\frac{1}{\\beta})$ then $X = \\sum_i^\\alpha X_i \\sim \\mathrm{Gamma}(\\alpha,\\beta)$. The PDF is given by:\n\n\\begin{equation}\nf_x = \\frac{1}{\\beta^\\alpha \\Gamma(\\alpha)}x^{\\alpha-1}e^{-x/\\beta}\n\\end{equation}\n\nWith $\\alpha,\\beta > 0$.\n\nAs one would expect, if $X_1 \\sim \\Gamma(\\alpha_1,\\beta)$ and $X_2 \\sim \\Gamma(\\alpha_2,\\beta)$ then $X_1 + X_2 \\sim \\Gamma(\\alpha_1+\\alpha_2,\\beta)$. \n\n\n\n% t distribution\n\\section{$t$-Distribution $\\mathrm{t_\\nu\\ }$}\n\n\\subsection{Cauchy Distribution $t_1$}\nThe Cauchy Distribution does not have a mean. It is infinite.\n\n\n\\section{Chi$^2$-Distribution $\\chi^2_p$}\nThe $\\chi^2$ distribution is the probability distribution of the sum of squares of standard normally distributed random variables. If $Z_i$ has standard normal distribution, then $X = \\sum_i^p Z_i \\sim \\chi^2_p$.\n\n\n% normal\n\\section{Normal $\\mathscr{N}(\\mu,\\sigma^2)$}\n\n\n\\subsection{Standard Normal Distribution $\\mathscr{N}(0,1)$ }\n\nThe normal distribution is so ubiquitous that there is notation specifically for the \\textit{standard normal distribution}, which is the normal distribution with parameters $\\mu = 0$ and $\\sigma = 1$. It is always possible to transform a random variable $X$ to have standard normal distribution by performing a coordinate transform. The PDF of the standard normal distribution is written $\\phi(x)$ and the CDF $\\Phi(x)$. The PDF is given by: \n\n\\begin{equation}\n\\phi(x) = \\frac{1}{\\sqrt{2\\pi}}\\exp{-x^2}\n\\end{equation}\n\nThe CDF has no closed form expression. \n\nBy convention, $Z$ is the random variable that has standard normal distribution. If $X \\sim \\mathscr{N}(\\mu,\\sigma^2)$, then $Z = \\frac{X-\\mu}{\\sigma} \\sim \\mathscr{N}(0,1)$. This standardizing transformation allows for calculations using lookup tables. \n\n\\subsubsection{Example: Interval $\\mathbb{P}(a 0$.\n\nThe Beta distribution is the conjugate prior to the Bernoulli and Binomial distributions.\n\n% dirichlet distribution\n\\section{Dirichlet $\\mathrm{Dirichlet}(\\mathbf{\\alpha})$}\nThe Dirichlet Distribution is the multivariate generalization of the Beta Distribution. Given $\\mathbf{X} = (X_1,...,X_K)$ and the parameter vector $\\mathbf{\\alpha} = (\\alpha_1,...,\\alpha_K),\\ \\alpha_j > 0$, the PDF is:\n\n\\begin{equation}\nf(\\mathbf{x},\\mathbf{\\alpha}) = \\frac{1}{B(\\mathbf{\\alpha})} \\prod^K_{i=1} x_i^{\\alpha_i -1}\n\\end{equation}\n\nWhere $B(\\mathbf{\\alpha})$ is the multivariate Beta function:\n\n\\begin{equation}\nB(\\mathbf{\\alpha}) = \\frac{\\prod^K_{i=1}\\Gamma(\\alpha_i)}{\\Gamma(\\sum_{i=1}^K\\alpha_i)}\n\\end{equation}\n\nThe Dirichlet distribution is the conjugate prior to the Multinoulli/Categorical and Multinomial distributions. The marginal distributions are Beta distributions, i.e. $X_i \\sim \\mathbf{Beta}(\\alpha_i,\\alpha_0-\\alpha_1)$ where $\\alpha_0 = \\sum_j \\alpha_j$.\n\n\n\n% multivariate normal distribution\n\\section{Multivariate Normal $\\mathscr{N}(\\mathbf{\\mu},\\mathbf{\\Sigma})$}\nThe multivariate normal distribution is the multivariate generalization of the normal distribution. The PDF is given by:\n\n\\begin{equation}\nf{\\mathbf{x}} = \\frac{1}{(2\\pi)^{\\frac{k}{2}}|\\Sigma|^{\\frac{1}{2}}}\\exp\\{-\\frac{1}{2}(\\mathbf{x}-\\mathbf{\\mu})^T \\mathbf{\\Sigma}^{-1}(\\mathbf{x}-\\mathbf{\\mu})\\}\n\\end{equation}\n\n\n\n% covariance matrix\n\\subsection{Covariance Matrix $\\mathbf{\\Sigma}$}\nThe covariance matrix $\\mathbf{\\Sigma}$ is symmetric and positive definite. Therefore, $\\mathbf{\\Sigma}^{\\frac{1}{2}}$ exists and is real, symmetric, and\n\n\\begin{itemize}\n\\item $\\mathbf{\\Sigma}^{\\frac{1}{2}}\\mathbf{\\Sigma}^{\\frac{1}{2}} = \\mathbf{\\Sigma}$\n\\item $\\mathbf{\\Sigma}^{\\frac{1}{2}}\\mathbf{\\Sigma}^{-\\frac{1}{2}}=\\mathbf{\\Sigma}^{-\\frac{1}{2}}\\mathbf{\\Sigma}^{\\frac{1}{2}}=\\mathbf{I}$\n\\end{itemize}\n\n\n% marginal distribution \n\\subsection{Marginal Distribution}\nIf $\\mathbf{X} \\sim \\mathscr{N}(\\mathbf{0},\\mathbf{\\Sigma})$, then the marginal distribution of $X_a$ is:\n\n\\begin{equation}\nX_a \\sim \\mathscr{\\mu_a,\\Sigma_{aa}}\n\\end{equation}\n\n\n% conditional distribution\n\\subsection{Conditional Distribution}\nIf $\\mathbf{X} \\sim \\mathscr{N}(\\mathbf{0},\\mathbf{\\Sigma})$, then the conditional distribution of $X_b$ given $X_a = x_a$ is:\n\n\\begin{equation}\nX_b|X_a = x_a \\sim \\mathscr{N}(\\mu_b + \\Sigma_{ba}\\Sigma_{aa}^{-1}(x_a - \\mu_a), \\Sigma_{bb}-\\Sigma_{ba}\\Sigma_{aa}^{-1}\\Sigma_{ab}) \n\\end{equation}\n\n\n% vector multiplication \n\\subsection{Vector Multiplication}\nIf $\\mathbf{a}$ is a vector, then:\n\n\\begin{equation}\n\\mathbf{a}^T \\mathbf{X} \\sim \\mathscr{N}(\\mathbf{a}^T \\mathbf{\\mu}, \\mathbf{a}^T\\mathbf{\\Sigma}\\mathbf{a})\n\\end{equation}\n\n\n% relationship to chi2\n\\subsection{Relationship to Chi$^2$}\n\\begin{equation}\nV = \\mathbf{Z}^T\\mathbf{Z} = (\\mathbf{X}-\\mathbf{\\mu})^T\\mathbf{\\Sigma}^{-1}(\\mathbf{X}-\\mathbf{\\mu}) \\sim \\chi^2_k\n\\end{equation}\n\n\\subsection{Multivariate Standard Normal Distribution $\\mathscr{N}(\\mathbf{0},\\mathbf{\\Sigma})$}\nThe standard multivariate normal distribution for $\\mathbf{Z} = (Z_1,...,Z_k)$ with $\\mathbf{Z} \\sim \\mathscr{N}(\\mathbf{0},\\mathbf{I})$ is:\n\n\\begin{equation}\nf(z) = \\prod^k_{i=1} f(z_i) = \\frac{1}{(2\\pi)^{\\frac{k}{2}}}\\exp \\{ \\frac{1}{2} \\sum^{k}_{j=1} z_j\\} = \\frac{1}{(2\\pi)^{\\frac{k}{2}}}\\exp \\{ \\frac{1}{2} \\mathbf{z^T z}\\}\n\\end{equation}\n\nThe transformation to a general multivariate normal random variable $\\mathbf{X}$ is that if $\\mathbf{Z} \\sim \\mathscr{0,\\mathbf{I}}$, then $\\mathbf{X} = \\mathbf{\\mu} + \\mathbf{\\Sigma}^{\\frac{1}{2}}\\mathbf{Z}$. Conversely, if $\\mathbf{X}\\sim \\mathscr{\\mathbf{\\mu},\\mathbf{\\Sigma}}$ then $\\mathbf{\\Sigma}^{-\\frac{1}{2}}(\\mathbf{X}-\\mathbf{\\mu}) \\sim \\mathscr{N}(0,\\mathbf{I})$.\n", "meta": {"hexsha": "0b08c06212ef8faa967d16d38482731751a0480a", "size": 17421, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/sections/proba_distributions.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/sections/proba_distributions.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/sections/proba_distributions.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.9385964912, "max_line_length": 931, "alphanum_fraction": 0.7243556627, "num_tokens": 5204, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418137109955, "lm_q2_score": 0.9184802501617068, "lm_q1q2_score": 0.8488060042421686}} {"text": "\\section{Clustering}\n\nTwo Views:\n\nClustering input: $S_n = \\{x^{(i)}|n=1,\\cdots,n\\}$\n\nClustering output are indexes for the data that partition the data: $C_1,\\cdots,C_k$; where $C_1 \\cup C_2 \\cup ... \\cup C_ K = \\big \\{ 1, 2, ..., n \\big \\}$ and the union of all $C_j$ 's is the original set and the intersection of any $C_i$ and $C_j$ is an empty set.\n\nRepresentatives of clusters: $z^{(1)},\\cdots,z^{(k)}$.\\\\\n\nCost of partitioning is the sum of costs of individual clusters: $cost(C_1,\\cdots,C_k) = \\sum_{j=1}^k cost (C_j)$. \n\nCost of cluster is sum of distances from data points to the representative of the cluster:$Cost(C,z) = \\sum_{i \\in C} = distance(x^{(i)},z)$\n\nCosine similarity: $cos(x^{(i)},x^{(j)}) = \\frac{x^{(i)} \\cdot x^{(j)}}{||x^{(i)}|| ||x^{(j)}||}$ is not sensitive of magnitude of vector (will not react to length).\\\\\n\nEuclidean square distance: $dist(x^{(i)},x^{(j)})= ||x^{(i)}-x^{(j)}||^2$. Will react to length.\\\\\n\n$cost(C_1,\\cdots,C_k; z^{(1)},\\cdots,z^{(k)}) = \\sum_{j=1}^k \\sum_{c \\in C_j} ||x^{(i)}-z^{(j)}||^2 $\n\n\\subsection{The K-Means Algorithm}\n\nOnly works with Euclidean square distance.\n\nGiven a set of feature vectors $S_ n = \\big \\{ x^{(i)}| i = 1,...,n\\big \\}$ and the number of clusters $K$ we can find cluster assignments $C_1,\\cdots,C_K$ and the representatives of each of the $K$ clusters $z_1,\\cdots,z_K$:\\\\\n\n\n\\begin{enumerate}\n\\item Randomly select $z_1,\\cdots,z_K$\n\\item Iterate\n\\begin{enumerate}\n\\item Given $z_1,\\cdots,z_K$, assign each data point $x^{(i)}$ to the closest $z_j$, so that $\\text {Cost}(z_1, ... z_ K) = \\sum _{i=1}^{n} \\min _{j=1,...,K} \\left\\| x^{(i)} - z_ j \\right\\| ^2$\n\\item Given $C_1,\\cdots,C_K$ find the best representatives $z_1,\\cdots,z_K$, i.e. find $z_1,\\cdots,z_K$ such that $\\displaystyle z_ j=\\operatorname {argmin}_{z} \\sum _{i \\in C_ j} \\| x^{(i)} - z \\| ^2$\n\\end{enumerate}\n\\end{enumerate}\n\nThe best representative is found by optimization (gradient with respect to $z^{(j)}$, setting to zero and solving for $z^{(j)}$). It is the centroid of the cluster: $z^{(j)}=\\displaystyle \\frac{\\sum _{i \\in C_ j} x^{(i)}}{|C_ j|}$\\\\\n\nThe clustering output that the K-Means algorithm converges to depends on the intialization.\nIn KM the fact that the z's are actually not guaranteed to be the members of the original set of points x\n\n\\subsection{K-Medoids Algorithm}\n\nFinds the cost-minimizing representatives $z_1,\\cdots,z_K$ for any distance measure. Uses real data points for initialization.\n\n\\begin{enumerate}\n\\item Randomly select $\\big \\{ z_1, ..., z_ K \\big \\} \\subseteq \\big \\{ x_1, ..., x_ n \\big \\}$\n\\item Iterate\n\\begin{enumerate}\n\\item Given $z_1,\\cdots,z_K$, assign each data point $x^{(i)}$ to the closest $z_j$, so that $\\text {Cost}(z_1, ... z_ K) = \\sum _{i=1}^{n} \\min _{j=1,...,K} \\left\\| x^{(i)} - z_ j \\right\\| ^2$\n\\item Given $C_ j \\in \\big \\{ C_1,...,C_ K\\big \\}$ find the best representative $z_ j \\in \\big \\{ x_1,...,x_ n\\big \\}$ such that $\\sum _{x^{(i)} \\in C_ j} \\text {dist}(x^{(i)}, z_ j)$ is minimal\n\\end{enumerate}\n\\end{enumerate}\n\n\\subsection{some useful notes:}\nmeasure of the cluster heterogeneity: cluster diameter (the distance\nbetween the most extreme feature vectors, i.e. the outliers),the average distance,\n the sum of the distances between every member and $z_j$, the\nrepresentative vector of cluster $C_j$.\n\n", "meta": {"hexsha": "f3ed15dfa1605b77bcc92275322826348fd8987f", "size": 3337, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "content/clustering.tex", "max_stars_repo_name": "sharov-am/MITx_capstone_2", "max_stars_repo_head_hexsha": "dfb1242b5984b29f0951ba9e14d96db9bf475d54", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "content/clustering.tex", "max_issues_repo_name": "sharov-am/MITx_capstone_2", "max_issues_repo_head_hexsha": "dfb1242b5984b29f0951ba9e14d96db9bf475d54", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "content/clustering.tex", "max_forks_repo_name": "sharov-am/MITx_capstone_2", "max_forks_repo_head_hexsha": "dfb1242b5984b29f0951ba9e14d96db9bf475d54", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.7049180328, "max_line_length": 273, "alphanum_fraction": 0.6535810608, "num_tokens": 1176, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897492587142, "lm_q2_score": 0.9019206824612297, "lm_q1q2_score": 0.8485177327039487}} {"text": "\\section{Lengths in metric spaces}\n\nOn $S^2 \\subset \\mathbb{R}^3$, we define $\\mathrm{d}(a,b) = \\text{inf}\\left( \\{ \\text{length}(\\gamma) | \\gamma \\text{ is a path on } S^2 \\text{ from } a \\text{ to } b \\} \\right)$, where $a$ and $b$ are points of $S^2$.\n\n\\noindent Now we try to generalize this construction. We assume that $X$ is a metric space.\n\n\\begin{itemize}\n \\item We will define \\emph{lengths of paths in} $X$.\n \\item Given lengths of paths, we will define a new distance $\\hat{d}$ on $X$ as follows:\n $$\\hat{d}(a,b) = \\text{inf}\\left( \\{ \\text{length}(\\gamma) \\ | \\ \\gamma \\text{ is a path from } a \\text{ to } b \\} \\right)$$\n where $a$ and $b$ are points of $X$.\n\\end{itemize}\n", "meta": {"hexsha": "95d2170170cca7518121121791ceb4b5b1e19bf6", "size": 691, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/LengthInMetricSpaces.tex", "max_stars_repo_name": "siddhartha-gadgil/MetricGeometryCourse", "max_stars_repo_head_hexsha": "92ec7727f358107a8ad61a7229bc94e2aa9bbafc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-12-28T05:53:38.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-20T05:56:59.000Z", "max_issues_repo_path": "src/LengthInMetricSpaces.tex", "max_issues_repo_name": "siddhartha-gadgil/MetricGeometryCourse", "max_issues_repo_head_hexsha": "92ec7727f358107a8ad61a7229bc94e2aa9bbafc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/LengthInMetricSpaces.tex", "max_forks_repo_name": "siddhartha-gadgil/MetricGeometryCourse", "max_forks_repo_head_hexsha": "92ec7727f358107a8ad61a7229bc94e2aa9bbafc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.1538461538, "max_line_length": 218, "alphanum_fraction": 0.6266280753, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9615338090839607, "lm_q2_score": 0.8824278772763472, "lm_q1q2_score": 0.8484842380793999}} {"text": "\\lab{Applications}{Correlation and Covariance}{Correlation and Covariance}\n\\label{Stats1}\n\n\\objective{This section will teach about using Python to solve problems in statistics. This will include finding means, correlation matrices, and solving least squares problems.}\n\n\\section*{Shifting Data by the Mean}\n\nConsider the table below representing students scores in a class.\\\\\n\n\\begin{figure}[h!]\n\\begin{center}\n\\begin{tabular}{|c|r|r|r|r|}\n\t\\hline\nStudent & Homework & Exam 1 & Exam 2 & Final \\\\\n\\hline\nS1 & 89 & 91 & 77 & 75 \\\\\nS2 & 67 & 72 & 76 & 66 \\\\\nS3 & 72 & 77 & 69 & 70 \\\\\nS4 & 56 & 60 & 55 & 61 \\\\\nS5 & 92 & 98 & 89 & 86 \\\\\nS6 & 83 & 88 & 90 & 84 \\\\\nS7 & 45 & 60 & 55 & 48 \\\\\n\\hline\nAverage & 72 & 78 & 73 & 70\\\\\n\\hline\n\\end{tabular}\\\\\n\\end{center}\n\\end{figure}\n\nWe can shift our data set by subtracting each column by its average value. This makes it so that the average of each column in the matrix below is zero. If $W$ represents the matrix of scores, the following Python command will subtract out the average. Why does this work?\n\\begin{lstlisting}[style=python]\n:X = W - sp.dot(sp.ones((7,1),dtype=sp.float_),sp.mean(W,axis=0).reshape(1,4));X\narray([[ 17., 13., 4., 5.],\n [ -5., -6., 3., -4.],\n [ 0., -1., -4., 0.],\n [-16., -18., -18., -9.],\n [ 20., 20., 16., 16.],\n [ 11., 10., 17., 14.],\n [-27., -18., -18., -22.]])\n\\end{lstlisting}\n\n\n\\section*{Angles Between Vectors}\n\nInner products give information about lengths of vectors and angles between vectors. Recall that the angle $\\theta$ between two vectors is given by\n\\[\n\\cos{\\theta} = \\frac{\\ipt{x}{y}}{\\norm{x}\\norm{y}}\n\\]\nwhere the norm (or length) of a vector is $\\norm{x} = \\sqrt{\\ipt{x}{x}}$. Note that the usual inner product in $\\mathbb{R}^n$ is given by\n\\[\n\\ipt{x}{y} = x^T y\n\\]\nAlternatively, if we can first divide our vectors by their length (these are called unit vectors) and then take the inner product\n\\[\n\\cos{\\theta} = \\left\\langle\\frac{x}{\\norm{x}},\\frac{y}{\\norm{y}}\\right\\rangle\n\\]\nHence, we can find the cosine of the angles between our data columns in $X$ by dividing each column by its length. There are a couple of ways of doing this. The following is an interesting way of doing it. Be sure to explore why it works:\n\\begin{lstlisting}[style=python]\n: Y = X / sp.dot(sp.ones((7,1),dtype=sp.float_),sp.sqrt(sp.diag(sp.dot(X.T,X)).T).reshape(1,4));Y\narray([[ 0.39848615, 0.35329218, 0.11386819, 0.15371887],\n [-0.11720181, -0.16305793, 0.08540114, -0.12297509],\n [ 0. , -0.02717632, -0.11386819, 0. ],\n [-0.37504578, -0.48917378, -0.51240685, -0.27669396],\n [ 0.46880723, 0.54352643, 0.45547275, 0.49190037],\n [ 0.25784398, 0.27176321, 0.4839398 , 0.43041282],\n [-0.63288976, -0.48917378, -0.51240685, -0.67636301]])\n\\end{lstlisting}\nHence we have:\n\\[\nY=\n\\begin{bmatrix}\n0.3985 & 0.3533 & 0.1139 & 0.1537\\\\\n-0.1172 & -0.1631 & 0.0854 & -0.1230\\\\\n0 &-0.0272 &-0.1139 & 0\\\\\n-0.3750 & -0.4892 & -0.5124 & -0.2767\\\\\n0.4688 & 0.5435 & 0.4555 & 0.4919\\\\\n0.2578 & 0.2718 & 0.4839 & 0.4304\\\\\n-0.6329 & -0.4892 & -0.5124 & -0.6764\n\\end{bmatrix}\n\\]\nFinally, we get the cosines of the angles between columns by computing $Y^T Y$. In Python, that's just\n\\begin{lstlisting}[style=python]\n: sp.dot(Y.T,Y)\narray([[ 1. , 0.97782999, 0.89014869, 0.94908967],\n [ 0.97782999, 1. , 0.90978843, 0.92490144],\n [ 0.89014869, 0.90978843, 1. , 0.9276955 ],\n [ 0.94908967, 0.92490144, 0.9276955 , 1. ]])\n\\end{lstlisting}\nThis yields\n\\[\nY^T Y = \n\\begin{bmatrix}\n1.0000 & 0.9778 & 0.8901 & 0.9491\\\\\n0.9778 & 1.0000 & 0.9098 & 0.9249\\\\\n0.8901 & 0.9098 & 1.0000 & 0.9277\\\\\n0.9491 & 0.9249 & 0.9277 & 1.0000\n\\end{bmatrix}.\n\\]\nNote that the $(j,k)$ entry of $Y^T Y$ corresponds to the cosine of the angle between the $j^{th}$ and $k^{th}$ columns. We remark that the diagonals are always equal to one because the angle between a vector and itself is zero and the cosine of zero is one.\n\nIt is also worth noting that the matrix resulting from the operation $A \\cdot A^T$ is symmetric and positive definite, so it can be solved with the cholesky decomposition that was discussed at the end of Lab \\ref{lab:LUdecomp}.\n\n\\section*{Correlation}\n\nWe remark that the cosine of the angle between two vectors is sometimes called the correlation coefficient. Two columns are said to be \n\\begin{itemize}\n\\item Perfectly correlated if the cosine of the angle between them is one.\n\\item Positively correlated if the cosine of the angle between them is between zero and one.\n\\item Uncorrelated if the cosine of the angle between them is zero.\n\\item Negatively correlated if the cosine of the angle between them is between negative one and zero.\n\\item Perfectly anticorrelated if the cosine of the angle between them is negative one.\n\\end{itemize}\n\nThe notion of correlation is important in establishing the relationships between measurements. For example, there is a high correlation between those who smoke and those who get lung cancer. It's important to understand that the high correlation alone does not necessarily imply that smoking causes lung cancer, it only links them statistically. This is the famous issue of causation versus correlation. For example, there is a high correlation between crime rates and sales of ice cream. This doesn't mean that ice cream causes crime or that increases in crime makes people want to eat more ice cream, but both rates do go up in the summer.\n\n\\begin{problem}\nLoad the data file \\texttt{data.npy}.\nThe dataset consists of two columns. Find the correlation coefficient of the two columns. Then plot the original data and see if the value that you got is reasonable.\n\\end{problem}\n", "meta": {"hexsha": "5172f61bcd048f329d93db9a22ea82b2391479c0", "size": 5773, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Applications/CorrCovariance/CorrCovariance.tex", "max_stars_repo_name": "abefrandsen/numerical_computing", "max_stars_repo_head_hexsha": "90559f7c4f387885eb44ea7b1fa19bb602f496cb", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Applications/CorrCovariance/CorrCovariance.tex", "max_issues_repo_name": "abefrandsen/numerical_computing", "max_issues_repo_head_hexsha": "90559f7c4f387885eb44ea7b1fa19bb602f496cb", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Applications/CorrCovariance/CorrCovariance.tex", "max_forks_repo_name": "abefrandsen/numerical_computing", "max_forks_repo_head_hexsha": "90559f7c4f387885eb44ea7b1fa19bb602f496cb", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1083333333, "max_line_length": 646, "alphanum_fraction": 0.6774640568, "num_tokens": 1947, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009573133051, "lm_q2_score": 0.9273632976542184, "lm_q1q2_score": 0.8484455688010679}} {"text": "\\section{Areas in the Plane}\r\n\\begin{lemma}\r\n\tIf $f(x) \\geq g(x)$ on $[a,b]$ then the area between $f(x)$ and $g(x)$ on $[a,b]$ is given by\r\n\t\\begin{equation*}\r\n\t\tA = \\int_{a}^{b}{\\left(f(x)-g(x)\\right)\\d{x}}.\r\n\t\\end{equation*}\r\n\\end{lemma}\r\n\r\nYou can easily visualize why this is true.\r\nWe can break the integral into two parts: adding the area under $f$ and the other subtracting the area under $g$.\r\nThe first integral will over count the area between $f$ and $g$, counting all area between $f$ and the $x$-axis.\r\nThe second integral will subtract exactly the amount of area that is over counted: the area that is also between $g$ and the $x$-axis.\r\n\r\n\\begin{figure}[H]\r\n\t\\label{area_between_curves}\r\n\t\\centering\r\n\t\\includegraphics[width = 0.33\\textwidth]{./applications_integrals/curve1.png}\r\n\t\\includegraphics[width = 0.33\\textwidth]{./applications_integrals/curve2.png}\r\n\t\\caption{\\hyperref{}{}{}{Subtracting two areas to get the area between them}}\r\n\\end{figure}\r\n\r\nEven if both of the curves has more area below the $x$-axis, the same idea applies.\r\n$f$ will give a smaller-magnitude negative area, while $g$ will give a larger magnitude negative area.\r\nSubtracting a larger-magnitude negative number from a smaller magnitude negative number will give a positive area.\r\n\r\n\\begin{example}\r\n\tFind the area enclosed between the two curves $y=2-x^2$ and $y=-x$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tThese two curves intersect at $x=-1$ and $x=2$.\r\n\tApplying the formula,\r\n\t\\begin{align*}\r\n\t\tA &= \\int_{-1}^{2}{((2-x^2)-(-x))\\d{x}} \\\\\r\n\t\t&= 2x-\\frac{x^3}{3} + \\frac{x^2}{2}\\biggr\\rvert_{-1}^{2} \\\\\r\n\t\t&= \\frac{9}{2}.\r\n\t\\end{align*}\r\n\\end{answer}\r\n\r\n\\subsection{Subregions}\r\nSometimes it might be useful to break the enclosed regions into subregions and find the area of each separately.\r\n\\begin{example}\r\n\tFind the area above the $x$-axis, below $y=\\sqrt{x}$, and above $y=x-2$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tIf we simply took the area between the two curves, we'd count some area we don't want beneath the $x$-axis\\footnote{Although this extra region is just a triangle and not too hard to find the area of, you'd effectively be applying the same strategy of two subregions, they'd just overlap. However, using geometry to your advantage is certainly a valid approach.}.\r\n\tInstead, we can break the area into two subregions: one between the $x$-axis and $\\sqrt{x}$ and the other between $x-2$ and $\\sqrt{x}$.\r\n\t\\begin{figure}[H]\r\n\t\t\\label{subregions}\r\n\t\t\\centering\r\n\t\t\\includegraphics[width = 0.33\\textwidth]{./applications_integrals/two_regions.png}\r\n\t\t\\caption{\\hyperref{}{}{}{Break complicated areas into simpler subregions}}\r\n\t\\end{figure}\r\n\t\r\n\tFinding the area of the blue region,\r\n\t\\begin{equation*}\r\n\t\tA_1 = \\int_{0}^{2}{\\sqrt{x}\\d{x}} = \\frac{2x\\sqrt{x}}{3}\\biggr\\rvert_0^2 = \\frac{4\\sqrt{2}}{3}.\r\n\t\\end{equation*}\r\n\t\r\n\tFinding the area of the green region,\r\n\t\\begin{equation*}\r\n\t\tA_2 = \\int_{2}^{4}{(\\sqrt{x}-(x-2))\\d{x}} = \\frac{2x\\sqrt{x}}{3} - \\frac{x^2}{2} + 2x \\biggr\\rvert_2^4 = \\frac{10}{3} - \\frac{4\\sqrt{2}}{3}.\r\n\t\\end{equation*}\r\n\t\r\n\tAdding the areas of the two regions,\r\n\t\\begin{equation*}\r\n\t\tA = A_1 + A_2 = \\frac{10}{3}.\r\n\t\\end{equation*}\r\n\\end{answer}\r\n\r\n\\subsection{Integrating with Respect to $y$}\r\nAnother strategy when finding the area of more complex regions is to see if they become easier to deal with if we were to instead integrate with respect to $y$.\r\nIn the above example, it is indeed easier to work with respect to $y$ because both bounding curves are between the same $y$ values.\r\n\\begin{example}\r\n\tFind the area above the $x$-axis, below $y=\\sqrt{x}$, and above $y=x-2$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tWe need to rearrange our equations to be of the form $x=\\ldots$ instead of $y=\\ldots$ by simply solving for $x$.\r\n\t\\begin{equation*}\r\n\t\tx = y^2, y\\geq 0 \\text{ and } x = y+2.\r\n\t\\end{equation*}\r\n\t\r\n\tSince $x=y+2$ is further from the $x$-axis, it becomes our top curve.\r\n\t\\begin{align*}\r\n\t\tA &= \\int_{0}^{2}{((y+2)-y^2)\\d{y}} \\\\\r\n\t\t&= \\frac{y^2}{2} + 2y - \\frac{y^3}{3} \\biggr\\rvert_0^2 \\\\\r\n\t\t&= \\frac{10}{3}.\r\n\t\\end{align*}\r\n\\end{answer}", "meta": {"hexsha": "6202098337d35100d86462acbc1f1e38c4bd2518", "size": 4082, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/applications_integrals/areas.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/applications_integrals/areas.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/applications_integrals/areas.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 46.3863636364, "max_line_length": 364, "alphanum_fraction": 0.6778539931, "num_tokens": 1344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632876167044, "lm_q2_score": 0.9149009578933863, "lm_q1q2_score": 0.8484455601556827}} {"text": "\n\\subsection{Polar co-ordinates}\n\n\\subsubsection{All complex numbers can be shown in polar form}\n\nConsider a complex number\n\n\\(z=a+bi\\)\n\nWe can write this as:\n\n\\(z=r\\cos(\\theta ) + ir\\sin(\\theta )\\)\n\n\\subsubsection{Polar forms are not unique}\n\nBecause the functions loop:\n\n\\(ae^{i\\theta }=a(\\cos(\\theta )+i\\sin(\\theta ))\\)\n\n\\(ae^{i\\theta }=a(\\cos(\\theta +n\\tau )+i\\sin(\\theta +n\\tau ))\\)\n\n\\(ae^{i\\theta }= ae^{i\\theta +n\\tau}\\)\n\nAdditionally:\n\n\\(ae^{i\\theta }=a(\\cos(\\theta )+i\\sin(\\theta ))\\)\n\n\\(ae^{i\\theta }=a(\\cos(\\theta )+i\\sin(\\theta ))\\)\n\n\\(ae^{i\\theta }=-a(\\cos(\\theta )-i\\sin(\\theta ))\\)\n\n\\(ae^{i\\theta }=-a(\\cos(\\theta +\\dfrac{\\pi }{2})+i\\sin(\\theta +\\dfrac{\\pi }{2}))\\)\n\n\\subsubsection{Real and imaginary parts of a complex number in polar form}\n\nWe can extract the real and imaginary parts of this number.\n\n\\(Re(z):=r\\cos (\\theta )\\)\n\n\\(Im(z):=r\\sin (\\theta )\\)\n\nAlternatively:\n\n\\(Re(z)=r\\dfrac{e^{i\\theta }+e^{-i\\theta }}{2}\\)\n\n\\(Im(z)=r\\dfrac{e^{i\\theta }-e^{-i\\theta }}{2i}\\)\n\n", "meta": {"hexsha": "433d89811d26a11094048b2fee7623efcd602c1c", "size": 992, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/trigonometryPolar/01-01-polar.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/trigonometryPolar/01-01-polar.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/trigonometryPolar/01-01-polar.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.6666666667, "max_line_length": 82, "alphanum_fraction": 0.6088709677, "num_tokens": 367, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9579122732859021, "lm_q2_score": 0.8856314783461302, "lm_q1q2_score": 0.8483572627160958}} {"text": "\\section{Probability Theory}\n\n\\begin{theorem}[Laws of Set Algebra]\n For any three sets $A$, $B$, $C$ all subsets of $S$, we have that the operators $\\cup$ and $\\cap$ are distributive, commutative, associative and satisfy DeMorgan's Laws:\n \\begin{align*}\n \\comp{(A \\cup B)} &= \\comp{A} \\cap \\comp{B} \\\\\n \\comp{(A \\cap B)} &= \\comp{A} \\cup \\comp{B}\n \\end{align*}\n\\end{theorem}\n\n\\begin{definition}[Sigma Algebra]\n A collections of subsets S is calles a \\emph{sigma algebra} (or \\emph{Borel Field}), denoted by $\\B{}$, if it has the following three properties:\n \\begin{enumerate}[a.]\n \\item $\\emptyset \\in \\B{}$\n \\item $A \\in \\B{} \\implies \\comp{A} \\in \\B{}$\n \\item If $A_i \\in \\B{}$ for $i$ in $\\mathcal{I}$ then $\\cup_{i\\in\\mathcal{I}}A_i \\in \\B{}$, where $\\mathcal{I}$ is countable. So $\\B{}$ is closed under countable union.\n \\end{enumerate}\n\\end{definition}\n\nNote that from DeMorgan's laws we have\n\\begin{equation}\n \\comp{\\left(\\bigcup_{i=1}^\\infty \\comp{A_i}\\right)} = \\bigcap_{i=1}^\\infty A_i\n\\end{equation}\nwhich means that, using b. we get $\\B{}$ is also closed under countable intersections $\\cap_{i=1}^\\infty A_i \\in \\B{}$.\n\n\\begin{definition}[Kolmogorov Axioms]\n Given a sample space $S$ and an associated sigma algebra $\\B{}$, a \\emph{probability function} is a function $\\P{}$ with domain $\\B{}$ that satisfies\n \\begin{enumerate}\n \\item $\\P{}(A) \\geq 0 \\quad \\forall A \\in \\B{}$\n \\item $\\P{}(S) = 1$\n \\item If $A_1, A_2, \\dots \\in \\B{}$ are pairwise disjoint, then $\\P{}(\\cup_{i=1}^\\infty A_i = \\sum_{i=1}^{\\infty})\\P{}(A_i)$\n \\end{enumerate}\n\\end{definition}\n\nThe following result makes it a bit easier to find probability functions.\n\n\\begin{theorem}\n Let $S=\\{s_1, s_2, \\dots\\}$ be a countable set. Let $\\B{}$ be any sigma algebra of subsets of $S$. Let $p_1, p_2, \\dots$ be nonnegative numbers that sum to 1. For any $A \\in \\B{}$, define $\\P{}(A)$ by\n \\[\n \\P{}(A) = \\sum_{\\{i: s_i \\in A\\}} p_i.\n \\]\nThen $\\P{}$ is a probability function on $\\B{}$.\n\\end{theorem}\n\n\\begin{definition}[Random Variable]\n A \\emph{random variable} is a function from a sample space $S$ into the real numbers.\n\\end{definition}\n\n\\begin{definition}[cdf]\n The \\emph{cumulative distribution function} of \\emph{cdf} of a random variable $X$ is defined by\n \\[\n F_X(x) = \\P{}_X(X \\leq x) \\quad \\forall x\n \\]\n\\end{definition}\n\n\\begin{theorem}\n The function $F(x)$ is a cdf if and only if:\n \\begin{enumerate}\n \\item $\\lim_{x \\to - \\infty} F(x) = 0$ and $\\lim_{x\\to\\infty} F(x) = 1$.\n \\item $F(x)$ is a non-decreasing function of x.\n \\item $F(x)$ is right-continuous, that is, for every number $x_0$, $\\lim_{x\\downarrow x_0} F(x) = F(x_0)$\n \\end{enumerate}\n\\end{theorem}\n\nWe say that a random variable is continuous if its cdf is continuous, and we say that it is discrete if its cdf is a step function.\n\n\\begin{theorem}\n The following statements are equivalent:\n \\begin{enumerate}\n \\item $X$ and $Y$ are identically distributed\n \\item $F_X(x) = F_Y(x) \\quad \\forall x$\n \\end{enumerate}\n\\end{theorem}\n\n\\begin{definition}[probability mass function]\n The \\emph{probability mass function} or \\emph{pmf} of a discrete random variable $X$ is\n \\[\n f_X(x) = P(X=x) \\quad \\forall x\n \\]\n\\end{definition}\n\n\\begin{definition}[probability density function]\n The \\emph{probability density function} or \\emph{pdf} of a continuous random variable $X$ is the function $f_X(x)$ that satisfies\n \\[\n F_X(x) = \\int_{-\\infty}^{x}f_X(t) \\d{} t \\quad \\forall x\n \\]\n\\end{definition}\n\n\\begin{theorem}\n A function $f_X(x)$ is a pdf (of pmf) of a random variable $X$ if and only if\n \\begin{enumerate}[a.]\n \\item $f_X(x) \\geq 0 \\quad \\forall x$\n \\item $\\sum_x f_X(x) = 1$ (pmf) or $\\int_x f_X(x)\\d{}x = 1$ (pdf).\n \\end{enumerate}\n\\end{theorem}\n\n\n\n\n\n\n", "meta": {"hexsha": "c6ec60dbb696e72c5e491bf8e349f42f0fb73229", "size": 3930, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/chapter1/content.tex", "max_stars_repo_name": "brynhayder/statistical_inference", "max_stars_repo_head_hexsha": "fc3e770650e9c145aa9d45e604c9e67624c2a013", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-01-25T05:52:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T07:20:16.000Z", "max_issues_repo_path": "notes/chapters/chapter1/content.tex", "max_issues_repo_name": "brynhayder/statistical_inference", "max_issues_repo_head_hexsha": "fc3e770650e9c145aa9d45e604c9e67624c2a013", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-17T15:44:01.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-24T09:31:29.000Z", "max_forks_repo_path": "notes/chapters/chapter1/content.tex", "max_forks_repo_name": "brynhayder/statistical_inference", "max_forks_repo_head_hexsha": "fc3e770650e9c145aa9d45e604c9e67624c2a013", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-04-29T11:11:32.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-17T09:47:07.000Z", "avg_line_length": 38.5294117647, "max_line_length": 204, "alphanum_fraction": 0.6259541985, "num_tokens": 1326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693716759488, "lm_q2_score": 0.8933094074745443, "lm_q1q2_score": 0.8483485837085646}} {"text": "\n\\subsection{Length of a curve}\n\nWe have a curve from \\(a\\) to \\(b\\) in \\(\\mathbf R^n\\).\n\n\\(f:[a,b]\\rightarrow \\mathbf R^n\\)\n\nWe divide this into \\(n\\) segments.\n\nThe \\(i\\)th cut is at:\n\n\\(t_i=a+\\dfrac{i}{n}(b-a)\\)\n\nSo the first cut is at:\n\n\\(t_0=a\\)\n\n\\(t_n=b\\)\n\nThe distance between two sequential cuts is:\n\n\\(||f(t_i)-f(t_{i-1}||\\)\n\nThe sum of all these differences is:\n\n\\(L=\\sum_{i=1}^n ||f(t_{i})-f(t_{i-1})||\\)\n\nThe limit is:\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n ||f(t_{i})-f(t_{i-1})||\\)\n\\subsubsection{Method 1}\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n ||f(t_{i})-f(t_{i-1})||\\)\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n ||\\dfrac{f(t_{i})-f(t_{i-1})}{\\Delta t}||\\Delta t\\)\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n ||f'(t)||\\Delta t\\)\n\n\\(L=\\int_a^b ||f'(t)||dt\\)\n\n\\subsubsection{Method 2}\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n ||f(t_{i})-f(t_{i-1})||\\)\n\n\\(L=\\lim_{n\\rightarrow \\infty }\\sum_{i=1}^n \\sqrt {(f(t_{i})-f(t_{i-1}))^*M(f(t_{i})-f(t_{i-1}))}\\)\n\n\\(L=\\int_a^b \\sqrt {(dt)^TM(dt)}\\)\n\n", "meta": {"hexsha": "e8be6c55218384a386b8f9f82bc50557d34f1d7b", "size": 1023, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/multiFunctions/01-04-length.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/multiFunctions/01-04-length.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/multiFunctions/01-04-length.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.8775510204, "max_line_length": 99, "alphanum_fraction": 0.5601173021, "num_tokens": 453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693659780479, "lm_q2_score": 0.8933093975331751, "lm_q1q2_score": 0.8483485691775623}} {"text": "One way of visualizing some relations is by using a directed graph, which we define below.\n\n\\begin{definition}\nA \\textbf{directed graph} consists of two sets $V$ and $E \\subset V \\times V$. The set $V$ is called the set of vertices and the set $E$ is called the set of (directed) edges. \n\\end{definition}\n\nWe can visualize a directed graph as follows. For visual purposes and a concrete example, we will consider the directed graph $V = \\{a, b, c\\}$ and $E = \\{(a, a), (a, b), (b, c), (c, c)\\}$. First, we imagine the objects of $V$ as dots.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{Ch3/vertices.png}\n\\end{figure}\n\nWe can imagine each object $(x, y)$ of $E$ as a ``directed arrow'' (ie an arrow) where the back end of the arrow is $x$ and the front end of the arrow is $y$. For the example graph pictured this is visualized as follows.\n\n\\begin{figure}[ht]\n\t\\centering\n\t\\includegraphics{Ch3/edges.png}\n\\end{figure}\n\nIn this way a graph can be visualized. One minor thing to observe is that any edge $(x, x)$ from an object $x$ to itself is drawn as a ``loop'' from the vertex starting at $x$ and pointing back at itself. The final thing to be observed is that any relation $R$ on a set $A$ can be seen as a graph. In this case, we take the vertices to be the set $A$ and we take the set of edges to be the set $R \\subset A \\times A$. We call this graph the \\textbf{associated graph} of the relation $R$.\n\n\\begin{example}\\label{gp1}\nSuppose that a relation $R$ is transitive. Recall that a relation $R$ is transitive if for all $a, b, c \\in A$, $(a, b) \\in R, (b, c) \\in R \\implies (a, c) \\in R$. What does this mean for its associated graph? Suppose then we have $a, b, c \\in A$ with $(a, b) \\in R, (b, c) \\in R$. Then $(a, c) \\in R$. A consequence of this is that if we have a chain of arrows from $a$ to $c$ then by transitivity there must be an arrow from $a$ to $c$ itself. This is illustrated in the picture below.\n\\end{example}\n\\begin{figure}[ht]\n\\centering\n\\includegraphics{Ch3/transitivity.png}\n\\end{figure}\n\n%remark. For any a in R transitivity implies that any vertex that can be reached by ``travelling'' through $a$ can be reached through a in one step (this might require induction `formally').\n\n\\subsubsection{Exercises}\n\n\\include{Ch3/rgraph_exercises}", "meta": {"hexsha": "3eae063c7156d369e06a4718a284b07e76e1b266", "size": 2274, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch3/rgraph.tex", "max_stars_repo_name": "jonlin1000/discr_math", "max_stars_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-22T03:31:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-14T02:26:40.000Z", "max_issues_repo_path": "Ch3/rgraph.tex", "max_issues_repo_name": "jonlin1000/discr_math", "max_issues_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch3/rgraph.tex", "max_forks_repo_name": "jonlin1000/discr_math", "max_forks_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 64.9714285714, "max_line_length": 487, "alphanum_fraction": 0.7106420405, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422227627597, "lm_q2_score": 0.8918110440002045, "lm_q1q2_score": 0.8482391386747318}} {"text": "\\chapter{Linear Maps}\n\\section{Vector spaces}\nA vector space over a field \\(F\\) is a set \\(V\\) that is closed under vector addition (+) and scalar multiplication (\\( \\cdot \\)). A vecotr space must fulfill following axioms:\n\\begin{align}\n \\begin{split}\n v, w, u \\in V \\\\\n \\alpha, \\beta \\in F \\\\\n v + w = u \\\\\n \\alpha \\cdot v = u \\\\\n (\\alpha \\cdot \\beta) \\cdot v = \\alpha \\cdot (\\beta \\cdot v) \\\\\n \\alpha (v + w) = \\alpha \\cdot v + \\alpha \\cdot w \\\\\n (\\alpha + \\beta) \\cdot w = \\alpha \\cdot v + \\beta \\cdot w \\\\\n 1 \\cdot v = w\n \\end{split}\n\\end{align}\nThe vector addition \\((V,+)\\) form a commutative group.\n\\begin{align*}\n (v + w) + u = v + (w + z) \\tag*{Associativity} \\\\\n v + 0 = V \\tag*{Identity element: zero vector} \\\\\n v + w = 0 \\tag*{Inverse element} \\\\\n v + w = w + v \\tag*{Commutativity} \\\\\n\\end{align*}\n\\( (F, +, \\cdot)\\) form a field.\n\\begin{align*}\n a, a^{-1}, b, c \\in F \\\\\n (a + b) + c = a + (b + c) \\tag*{Additive associativity} \\\\\n a + a^{-1} = 0 \\tag*{Additive inverse} \\\\\n a + 0 = a \\tag*{Additive identity} \\\\\n a + b = b + a \\tag*{Additive commutativity} \\\\\n (a \\cdot b) \\cdot c = a \\cdot (b \\cdot c) \\tag*{Mulitlicative associativity} \\\\\n a \\cdot a^{-1} = 1, a^{-1} \\neq 0 \\tag*{Mulitlicative inverse} \\\\\n a \\cdot 1 = a \\tag*{Multiplicative identity} \\\\\n a \\cdot b = b \\cdot a \\tag*{Mulitplicative commutativity} \\\\\n a \\cdot (b + c) = a\\cdot b + \\cdot c \\tag*{Distibutivity}\n\\end{align*}\nExample for fields: \\((\\mathbb{R}, +, \\cdot)\\) \\( (\\mathbb{C}, +, \\cdot)\\) \\\\\nExample for non fields: \\((\\mathbb{N}, +, \\cdot)\\) \\( (\\mathbb{Z}, +, \\cdot)\\) \\\\\n\\subsection{Subspace}\nLet \\(V\\) be a vector space ofer a field \\(F\\). A subspace \\(W\\) is a subset of \\(V\\) that also form a vector space over \\(F\\).\n\\begin{example}\n \\(\\mathbb{R}^2\\) is a vector space over \\(\\mathbb{R}\\).\n \\begin{align*}\n W = \\setb{c \\cdot \\begin{bmatrix}\n 1 \\\\2\n \\end{bmatrix}\n }{c \\in \\mathbb{R}} = \\{ \\dots \\begin{bmatrix}\n -1 \\\\ -2\n \\end{bmatrix}, \\begin{bmatrix}\n 1 \\\\2\n \\end{bmatrix}, \\begin{bmatrix}\n 2 \\\\4\n \\end{bmatrix},\\begin{bmatrix}\n 2.4 \\\\ 4.8\n \\end{bmatrix} \\dots\n \\}\n \\end{align*}\n\\end{example}\n\\subsubsection{Direct sum}\nLet \\(V\\) be a vector space ofer a field \\(F\\) and \\(W\\) and \\(U\\) subspaces of \\(V\\)\nWhen:\n\\begin{align}\n W \\cap U & = \\{ 0 \\} \\\\\n W \\cup U & = V\n\\end{align}\nThen \\(U\\) and \\(W\\) are a direct sum of \\(V\\). It is denoted by\n\\begin{equation}\n V = U \\oplus W\n\\end{equation}\n\\subsection{Span, (lineare Hülle)}\nLet \\(V\\) be a vector space ofer a field \\(F\\) and \\(S\\) a finite subset of \\(V\\) wiht length \\(n\\). The span of \\(S\\) is the set of vectors that can be created by linear combinations with the vectors in \\(S\\).\n\\begin{equation}\n span(S) = \\setb{\n \\sum_{i=1}^{n} a_i \\cdot s_i\n }{n \\in \\mathbb{N}, a_i \\in F, s_i \\in S}\n\\end{equation}\n\\begin{example}\n \\begin{align*}\n S & = \\{\n \\begin{bmatrix}\n 1 \\\\ 0 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix}\n 0 \\\\ 1 \\\\ 0\n \\end{bmatrix}\n \\} \\\\\n \\vspan S & = \\setb{\n a_1\n \\begin{bmatrix}\n 1 \\\\ 0 \\\\ 0\n \\end{bmatrix} + a_2\n \\begin{bmatrix}\n 0 \\\\ 1 \\\\ 0\n \\end{bmatrix}\n \\\n }{a_1, a_2 \\in \\mathbb{R}}\n \\end{align*}\n\\end{example}\n\\subsubsection{Spanning set}\nLet \\(V\\) be a vector space ofer a field \\(F\\) and \\(S\\) a finite subset of \\(V\\). \\(S\\) is a spanning set of if\n\\begin{equation}\n \\vspan S = V\n\\end{equation}\n\\begin{example}\n Let \\(V\\) be \\(\\mathbb{R}^2\\) over the field \\(\\mathbb{R}\\). Following subsets are spanning set of \\(V\\):\n \\begin{align*}\n S_1 & = \\{ \\begin{bmatrix}\n 1 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n \\} \\\\\n S_2 & = \\{ \\begin{bmatrix}\n 3 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix} 0 \\\\ 2 \\end{bmatrix}\n \\} \\\\\n S_3 & = \\{ \\begin{bmatrix}\n 3 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix} 0 \\\\ 2 \\end{bmatrix},\n \\begin{bmatrix} 1 \\\\ 2 \\end{bmatrix}\n \\}\n \\end{align*}\n\\end{example}\n\\subsection{Base}\nLet \\(V\\) be a vector space ofer a field \\(F\\) and \\(B\\) a spanning set of \\(V\\). If the elements of \\(B\\) are lineary independent then \\(B\\) is called a basis.\nThe coefficients of the linear combination are referred to as components or coordinates of the vector with respect to \\(B\\).\nThe elements of \\(B\\) are called basis vectors.\n\\begin{example}\n Let \\(V\\) be \\(\\mathbb{R}^2\\) over the field \\(\\mathbb{R}\\). Following subsets are spanning set of \\(V\\):\n \\begin{align*}\n B_1 & = \\{ \\begin{bmatrix}\n 1 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n \\} \\\\\n B_2 & = \\{ \\begin{bmatrix}\n 3 \\\\ 0\n \\end{bmatrix},\n \\begin{bmatrix} 0 \\\\ 2 \\end{bmatrix}\n \\} \\\\\n \\end{align*}\n In previous example \\(S_3\\) is not a valid base, because its elements are lineary dependent.\n\\end{example}\n\\subsubsection{Standard base}\nA base \\(B\\) is called a Standard base if the vecotors of \\(B\\) are all zero, except one that equals 1. The vectors\nof the standard base are called unit vectors.\n\\begin{example}\n The standard base for \\(\\mathbb{R}^n\\) is\n \\begin{align*}\n \\hat{i} & = \\begin{bmatrix}\n 1 \\\\ 0 \\\\ 0\n \\end{bmatrix}, \\hat{j} = \\begin{bmatrix}\n 0 \\\\ 1 \\\\ 0\n \\end{bmatrix}, \\hat{k} = \\begin{bmatrix}\n 0 \\\\ 0 \\\\ 1\n \\end{bmatrix} \\\\\n B & = \\{ \\hat{i}, \\hat{j}, \\hat{k} \\}\n \\end{align*}\n A vector \\(v\\) expressed in the standard basis \\(B\\).\n \\begin{align*}\n v = \\begin{bmatrix}\n 4 \\\\ 5 \\\\ 6\n \\end{bmatrix}= 4 \\hat{i} + 5 \\hat{j} + 6 \\hat{k}\n \\end{align*}\n\\end{example}\n\\subsection{Dimension}\\label{dimension}\nThe dimension \\( \\dim \\) of a vector space is the size of its base \\(B\\). The dimension\nis equal to the rank (see \\ref{rank}) of the tranformation matrix.\n\\begin{example}\n The vector space \\(\\mathbb{R}^n\\)\n \\begin{align*}\n \\dim \\mathbb{R}^n = n\n \\end{align*}\n\\end{example}\n\\begin{example}\n \\begin{align*}\n V & = \\setb{\n c_1\n \\begin{bmatrix}\n 1 \\\\ 0 \\\\ 0 \\\\ 0\n \\end{bmatrix},\n c_2\n \\begin{bmatrix}\n 0 \\\\ 1 \\\\ 0 \\\\ 0\n \\end{bmatrix}\n }{c_1, c_2 \\in \\mathbb{R}} \\\\\n \\dim V & = 2\n \\end{align*}\n\\end{example}\n\\begin{example}\n \\begin{align*}\n V & = \\setb{\n c_1\n \\begin{bmatrix}\n 1 \\\\ 1 \\\\ 0 \\\\ 0\n \\end{bmatrix},\n c_2\n \\begin{bmatrix}\n 0 \\\\ 1 \\\\ 0 \\\\ 0\n \\end{bmatrix}\n }{c_1, c_2 \\in \\mathbb{R}} \\\\\n \\dim V & = 1\n \\end{align*}\n\\end{example}\n\\begin{example}\n The only vector space with dimension 0 is where V contains only the zero vector.\n \\begin{align*}\n \\dim \\{ \\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\end{bmatrix}\\} = 0\n \\end{align*}\n\n\\end{example}\nsection{Linear maps}\nLet \\(V\\) \\(W\\) be vector spaces over the same field \\(F\\).\nA function \\(f: V \\rightarrow W\\) is said to be a linear map if for any two vectors \\(v, u \\in V\\) and any scalar \\(c \\in F\\) the following two conditions are satisfied:\n\\begin{align}\n f(u + v) & = f(u) + f(v) \\tag{Additvity} \\\\\n f(c \\cdot u) & = c \\cdot u \\tag{Homogenity}\n\\end{align}\n\\subsection{Transformation matrix}\nEach linear transformation can be represented as a matrix vector multiplication.\n\\begin{align*}\n f & : W \\rightarrow V \\\\\n \\dim W & = n, \\dim V = m \\\\\n f(x) & = A^{m \\times n} x \\\\\n\\end{align*}\n\\begin{example}\n \\begin{align*}\n f(x) &\n = \\begin{bmatrix}\n 1 & 2 & 3 \\\\ 5 & 7 & 9\n \\end{bmatrix} \\begin{bmatrix}\n x_1 \\\\ x_2 \\\\ x_3\n \\end{bmatrix} \\\\\n f \\left(\\begin{bmatrix}\n 5 \\\\ 6 \\\\ 7\n \\end{bmatrix} \\right) & = \\begin{bmatrix}\n 38 \\\\ 130\n \\end{bmatrix}\n \\end{align*}\n\\end{example}\n\\subsubsection{Composition}\nIf there are two linear maps \\(f, g\\) wiht tranformation matrices:\n\\begin{align*}\n f : V \\rightarrow W = Ax \\\\\n g : U \\rightarrow V = Bx\n\\end{align*}\nthen the compostition is:\n\\begin{align*}\n h : U \\rightarrow W = f \\circ g \\\\\n h(x) = A(Bx) = (A \\cdot B)x\n\\end{align*}\n\\begin{example}\n \\begin{align*}\n f(x) & = \\begin{bmatrix}\n 1 & 2 & 3 \\\\ 5 & 7 & 9\n \\end{bmatrix} \\cdot x \\\\\n g(x) & = \\begin{bmatrix}\n -1 & -2 \\\\ -7 & -9 \\\\ 13 & 17\n \\end{bmatrix} \\cdot x \\\\\n h(x) & = f \\circ g = \\begin{bmatrix}\n 1 & 2 & 3 \\\\ 5 & 7 & 9\n \\end{bmatrix} \\begin{bmatrix}\n -1 & -2 \\\\ -7 & -9 \\\\ 13 & 17\n \\end{bmatrix} \\cdot x = \\begin{bmatrix}\n 24 & 31 \\\\ 64 & 80\n \\end{bmatrix} \\cdot x \\\\\n g \\left( \\begin{bmatrix}\n 3 \\\\ 4\n \\end{bmatrix} \\right) & = \\begin{bmatrix}\n -11 \\\\ -57 \\\\ 107\n \\end{bmatrix}, f \\left( \\begin{bmatrix}\n -11 \\\\ -57 \\\\ 107\n \\end{bmatrix} \\right) = \\begin{bmatrix}\n 196 \\\\ 509\n \\end{bmatrix} \\\\\n h(\\begin{bmatrix}\n 3 \\\\ 4\n \\end{bmatrix}) & = \\begin{bmatrix}\n 196 \\\\ 509\n \\end{bmatrix}\n \\end{align*}\n\\end{example}\n\\subsection{Image (Bild)}\nThe image \\(f^{\\rightarrow}\\) of a tranformation \\(L: V \\rightarrow W \\) is the set of vectors that the tranformation can produce.\n\\begin{equation}\n f^{\\rightarrow} (L) = \\setb{L(x)}{x \\in V}\n\\end{equation}\nThe image is the columnspan of the tranformation matrix. The dimenson of the image ist called \\textbf{rank}, and is the\nsame as the rank of the transformation matrix.\n\\begin{example}\n \\begin{align*}\n L(x) & = \\begin{bmatrix}\n 1 & 0 \\\\\n 0 & 1 \\\\\n \\end{bmatrix}x \\\\\n f^{\\rightarrow} (L) & = \\mathbb{R}^2\n \\end{align*}\n\\end{example}\n\\begin{example}\n \\begin{align*}\n L(x) & = \\begin{bmatrix}\n 1 & 0 \\\\\n 2 & 0 \\\\\n 1 & 1 \\\\\n 0 & 2 \\\\\n \\end{bmatrix}x \\\\\n f^{\\rightarrow} (L) & = \\setb{\\begin{bmatrix}\n c_1 \\\\ 2c_1 \\\\ c_1 + c_2 \\\\ 2 c_2\n \\end{bmatrix}\n }{c_1, c_2 \\in \\mathbb{R}}\n \\end{align*}\n\\end{example}\n\\subsection{Kernel, Null Space (Kern)}\\label{kernel}\nThe kernel of a linear map \\(L: V \\rightarrow W \\) is the linear subspace of the domain of the map which is mapped to the zero vector.\n\\begin{equation}\n \\ker L = \\{ v \\in V | L(v) = 0 \\} \\\\\n\\end{equation}\n\nThe vecots of the kernel are the set of vectors that yield the zero vector after multiplication with the tranformation matrx.\n\\begin{align*}\n L & : Ax = y \\\\\n x' & \\in \\ker L \\textbf{ if } Ax' = 0\n\\end{align*}\nThe kernel forms a subspace of \\( V \\):\n\\begin{align*}\n v, u \\in \\ker L, \\alpha \\in \\mathbb{F} \\\\\n \\alpha v \\in \\ker L \\\\\n v + u \\in \\ker L \\\\\n\\end{align*}\nThe dimension of the kernel is called the \\textbf{nullity}.\n\\begin{example}\n \\begin{align*}\n L & : Ax = y \\\\\n A & = \\begin{bmatrix}\n 1 & -1, & 0 \\\\\n 0 & -2 & 4 \\\\\n \\end{bmatrix} & \\\\\n \\end{align*}\n To calculate \\( \\ker A\\) simply set \\(y\\) to the zero vector and solve for \\(x\\).\n \\begin{align*}\n \\begin{bmatrix}\n 1 & -1, & 0 \\\\\n 0 & -2 & 4 \\\\\n \\end{bmatrix} \\begin{bmatrix}\n x_1 \\\\\n x_2 \\\\\n x_3 \\\\\n \\end{bmatrix} = \\begin{bmatrix}\n 0 \\\\ 0 \\\\ 0\n \\end{bmatrix} \\\\\n x_1 - x_2 = 0 \\rightarrow x_1 = x_2 \\\\\n -2 x_2 + 4 x_3 = 0 \\rightarrow x_2 = 2 x_3 \\\\\n \\end{align*}\n The kernel is:\n \\begin{align*}\n \\ker L & = \\setb{\n c \\cdot \\begin{bmatrix}\n 2 \\\\ 2 \\\\ 1\n \\end{bmatrix}\n }{c \\in \\mathbb{C} }\n \\end{align*}\n A concrete example:\n \\begin{align*}\n \\begin{bmatrix}\n 4 \\\\ 4 \\\\ 2\n \\end{bmatrix} & \\in \\ker L \\\\\n L \\left(\\begin{bmatrix}\n 4 \\\\ 4 \\\\ 2\n \\end{bmatrix} \\right) & = \\begin{bmatrix}\n 1 \\cdot 4 -1 \\cdot 4 + 0 \\cdot 2 \\\\\n 0 \\cdot 4 -2 \\cdot 4 + 4 \\cdot 2 \\\\\n \\end{bmatrix} = \\begin{bmatrix}\n 0 \\\\ 0\n \\end{bmatrix} \\\\\n \\end{align*}\n \\begin{example}\n\n \\end{example}\n \\section{Rank-Nullity theorem}\n If \\(L : V \\rightarrow W\\) is a linear tranformation then it.\n \\begin{equation}\n \\rank L + \\nullity T = \\dim (image T) + \\dim(\\ker(T)) = \\dim(V)\n \\end{equation}\n \\begin{example}\n \\begin{align*}\n L & : \\begin{bmatrix}\n 1 & 0 \\\\ 0 & 1\n \\end{bmatrix} x = y \\\\\n image T & = \\mathbb{R}^2 \\\\\n \\rank L & = 2 \\\\\n \\ker T & = \\{ \\begin{bmatrix}\n 0 \\\\ 0\n \\end{bmatrix} \\} \\\\\n \\nullity L & = 0 \\\\\n \\dim V & = \\rank L + \\nullity T = 2 +0 = 2\n \\end{align*}\n \\end{example}\n \\begin{example}\n \\begin{align*}\n L & : \\begin{bmatrix}\n 1 & 2 & 4 \\\\ 2 & 4 & 8\n \\end{bmatrix} x = y \\\\\n imag L & = \\setb{\n \\begin{bmatrix}\n c \\\\ 2 c\n \\end{bmatrix}\n }{c \\in \\mathbb{R}}\n \\end{align*}\n \\begin{align*}\n \\rank L = 1 \\\\\n \\ker L = \\setb{\n \\begin{bmatrix}\n -2 c_1 - 4 c_2 \\\\ c_1 \\\\ c_2\n \\end{bmatrix}\n }{ c_1, c_2 \\in \\mathbb{R}}\n \\nullity A = 2\n \\end{align*}\n \\end{example}\n\\end{example}", "meta": {"hexsha": "666e4ee265b2fc42d7f7ef2466c4257b07911fa7", "size": 15131, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/liner_maps.tex", "max_stars_repo_name": "KriCse/Math-knowledge", "max_stars_repo_head_hexsha": "92c036c4563999ddaa97888a4023297e22bb7649", "max_stars_repo_licenses": ["WTFPL"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/liner_maps.tex", "max_issues_repo_name": "KriCse/Math-knowledge", "max_issues_repo_head_hexsha": "92c036c4563999ddaa97888a4023297e22bb7649", "max_issues_repo_licenses": ["WTFPL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/liner_maps.tex", "max_forks_repo_name": "KriCse/Math-knowledge", "max_forks_repo_head_hexsha": "92c036c4563999ddaa97888a4023297e22bb7649", "max_forks_repo_licenses": ["WTFPL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.1121718377, "max_line_length": 210, "alphanum_fraction": 0.4562818056, "num_tokens": 4863, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422213778251, "lm_q2_score": 0.8918110432813418, "lm_q1q2_score": 0.8482391367558911}} {"text": "\\section{The symmetric group}\nGiven a set $X$, the class of all bijections $\\pi \\in Bij(X,X)$ is called the symmetric group\n$$S(X),\\ \\tmr{or}\\ S_X.$$\nIn particular, given the integer interval $N := \\{1,\\ldots,n\\} \\subset \\zz$ we call\n$$S_N := S_n$$\nthe $n$-th symmetric group.\n\\subsection{Representation theory of $S_n$}\nThe first to mention is the \n\\subsubsection{Trivial representation of $S_n$}\nGiven a unital commutative ring $R$, then the pair $(R,\\rho_R)$\n$$S_n \\ni \\pi \\stackrel{\\rho_R}{\\longmapsto} 1_R$$\nis called the trivial representation of $S_n$. We only mention it for completeness - as it will be used later on.\n\\subsubsection{Permutation representation of $S_n$}\nGiven $R$ and $S_n$ as above, we call\n$$(M,\\rho_{\\tmr{perm}}),\\ M = R^n,\\ \\pi \\longmapsto \\sum_{i=1}^n e_{\\pi(i)i}$$\nthe permutation representation of $S_n$. Note, that although most often $R$ to be an algebraic field it need not be - $\\zz$ as the initial object in the category of unital rings is sufficient.\n\\subsubsection{Standard representation of $S_n$}\nAgain, $R$, $S_n$ and now $M$ as above - we get \n$$(M',\\rho_{\\tmr{std}}),\\ M' = \\left \\subsetneq M,\\ \\pi \\longmapsto \\left[\\sum_i^{n-1} \\lambda_i \\alpha_i \\longmapsto \\sum_i \\lambda_i \\right]$$\nthe standard representation. Here, $e_i$ denotes the canonical generators of $M$ and $\\alpha_i = e_i - e_n$ are our generators. Let us expand:\n$$\\sum_i \\lambda_i \\alpha_i = \\sum_i \\lambda_i (e_i - e_n)\\longmapsto \\sum_i \\lambda_i (e_{\\pi(i)} - e_{\\pi(n)}) ) = \\sum_i \\lambda_i(e_{\\pi(i)} - e_n + e_n - e_{\\pi(n)}) = \\sum_i \\lambda_i (\\alpha_{\\pi(i)} - \\alpha_{\\pi(n)})$$\nIn this context, $\\alpha_{\\pi(n)}$ is simply either zero if $\\pi(n) = n$, otherwise $\\pi(n) < n$ and thus there is an element $\\alpha_{\\pi(n)}$. I.e.:\n$$\\alpha_i \\longmapsto \\alpha_{\\pi(i)} - (1 - \\delta_{\\pi(n),n}) \\alpha_{\\pi(n)}\\ \\forall 1 \\leq i \\leq n - 1.$$ \nIn conclusion:\n$$\\pi \\longmapsto \\sum_{i=1}^{n-1} \\left(f_{\\pi(i)i} - (1 - \\delta_{\\pi(n),n}) f_{\\pi(n)i}\\right)$$\nwhere $f_{ji} = [\\alpha_i \\longmapsto \\alpha_j] \\in \\tmr{End}_R(M')\\ \\forall 1 \\leq i,j \\leq n - 1$.\nThe alert reader will have noticed that we already employed the following\n\\begin{prop} The permutation representation $(M,\\rho_{\\tmr{perm}})$ decomposes into the trivial and standard representation:\n$$(M,\\rho_{\\tmr{perm}}) = (M',\\rho_{\\tmr{std}}) \\oplus (M'',\\rho_{\\tmr{trivial}}).$$\n\\end{prop}\nWe already saw that $M'$ is an $S_n$ submodule of $M$. The trivial representation is given by\n$$M'' := \\left<\\sum_{i=1}^n e_i\\right>$$\nand the fact that any $\\pi \\in S_n$ operates trivially on $\\sum_i e_i$ (i.e. just a reshuffle of the summands).", "meta": {"hexsha": "b3750648e96e13915ada10b2fb607cd414ef1caa", "size": 2665, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "symm_grp_rep/symmetric.tex", "max_stars_repo_name": "gmuel/texlib", "max_stars_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "symm_grp_rep/symmetric.tex", "max_issues_repo_name": "gmuel/texlib", "max_issues_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "symm_grp_rep/symmetric.tex", "max_forks_repo_name": "gmuel/texlib", "max_forks_repo_head_hexsha": "1a3fab54f2e03d9ce656f9b8a5b58e26c3c93a02", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 80.7575757576, "max_line_length": 227, "alphanum_fraction": 0.6682926829, "num_tokens": 946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813538993889, "lm_q2_score": 0.8872045847699185, "lm_q1q2_score": 0.8481510401340918}} {"text": "\\section{Mean Value Theorem for Derivatives}\r\n\\begin{theorem}[Mean Value Theorem for Derivatives]\r\n\tIf $f$ is continuous on the interval $[a,b]$ and differentiable on the interval $(a,b)$, then there exists at least one point in $(a,b)$ such that\r\n\t\\begin{equation*}\r\n\t\tf^\\prime(c) = \\frac{f(b)-f(a)}{b-a}.\r\n\t\\end{equation*}\r\n\\end{theorem}\r\n\r\nThat is, there's at least one point where the instantaneous rate of change and average rate of change are equal.\r\nAnother way of visualizing this is that there's al least one point where the tangent and secant lines are parallel.\r\n\r\n\\begin{figure}[H]\r\n\t\\label{mvt}\r\n\t\\centering\r\n\t\\includegraphics[width = 0.5\\textwidth]{./applications_derivative/mvt.png}\r\n\t\\caption{\\hyperref{https://en.wikipedia.org/wiki/Mean\\_value\\_theorem}{}{}{Wikipedia - Mean Value Theorem}}\r\n\\end{figure}\r\n\r\n\\begin{example}\r\n\tA trucker drives 150 miles of a route in 2 hours.\r\n\tThe speed limit along the route is 65 miles per hour.\r\n\tShow that at at least one point, the trucker must have been speeding.\r\n\\end{example}\r\n\\begin{answer}\r\n\tWe can model the trucker's position along the route $s$ as a function of time $t$ where $s(0)=0$ and $s(2)=150$.\r\n\tWe know that velocity is the derivative of position, so $v(t) = s^\\prime(t)$.\r\n\tIt's reasonable to assume that $s$ is differentiable on the interval $[0,2]$.\r\n\tSo, by the Mean Value Theorem, there must exist a point $c$ where\r\n\t\\begin{equation*}\r\n\t\tv(t) = \\frac{s(2)-s(0)}{2-0} = \\frac{150-0}{2} = 75\\text{mph}.\r\n\t\\end{equation*}\r\n\tAt this point, the trucker was exceeding the speed limit of 65 miles per hour.\r\n\\end{answer}\r\n\r\n\\begin{definition}\r\n\tLet $f$ be defined on an interval $I$.\r\n\tLet $a$ and $b$ be any two different points in $I$.\r\n\t\\begin{align*}\r\n\t\t\\text{$f$ increases on $I$ if } a < b &\\implies f(a) < f(b). \\\\\r\n\t\t\\text{$f$ decreases on $I$ if } a < b &\\implies f(a) > f(b).\r\n\t\\end{align*}\r\n\\end{definition}\r\n\r\n\\begin{corollary}\r\n\tLet $f$ be continuous of $[a,b]$ and differentiable on $(a,b)$.\r\n\t\\begin{align*}\r\n\t\t\\text{If $f^\\prime > 0$ at every point on $(a,b)$ then $f$ increases on $[a,b]$}. \\\\\r\n\t\t\\text{If $f^\\prime < 0$ at every point on $(a,b)$ then $f$ decreases on $[a,b]$}.\r\n\t\\end{align*}\r\n\\end{corollary}\r\n\r\nThis should make sense given our theorem about local extrema.\r\nIf $f$ could still increase/decrease while its derivative was negative/positive, then we couldn't be sure that $f$ is at a local maxima/minima when $f^\\prime=0$.\r\n\r\n\\begin{corollary}\r\n\tIf $f^\\prime(x) = 0$ at all points in an interval $I$, then there is some constant $C$ such that $f(x) = C$ for all points in $I$.\r\n\\end{corollary}\r\n\r\nThis follows from the Mean Value Theorem.\r\nSince $f^\\prime = 0$, the numerator in the Mean Value Theorem, $f(b) - f(a)$, must also be 0, meaning $f(b) = f(a) = C$.\r\n\r\n\\begin{corollary}\r\n\tIf $f^\\prime(x) = g^\\prime(x)$ at ever point in some interval $I$, then there is come constant $C$ such that $f(x) = g(x) + C$.\r\n\\end{corollary}\r\n\r\nThat is, functions with the same derivative differ by a constant.\r\nThis should make sense given our constant and sum and difference derivative rules.\r\nIf we let $h^\\prime(x) = f^\\prime(x) - g^\\prime(x) = 0$ and apply the previous corollary, we get $C$.\r\n\r\n\\begin{definition}\r\n\tA function $F(x)$ is the antiderivative\tof $f(x)$ if $F^\\prime(x) = f(x)$ for all points in the domain of $f$.\r\n\\end{definition}\r\n\r\nAs we saw in the previous corollary, a function will have infinitely many antiderivatives that differ by a constant.", "meta": {"hexsha": "98ea1d5851736c885d7be8b8ee755e2bad6c1fc6", "size": 3463, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/applications_derivative/mvt.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "calc/applications_derivative/mvt.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "calc/applications_derivative/mvt.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.7972972973, "max_line_length": 162, "alphanum_fraction": 0.6788911349, "num_tokens": 1081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813513911655, "lm_q2_score": 0.8872045862611166, "lm_q1q2_score": 0.8481510393343421}} {"text": "\n\\subsection{Curl}\n\nThe curl of a vector field is defined as:\n\n\\(curl \\mathbf F=\\nabla \\times \\mathbf F\\)\n\nWhere: \\(\\nabla =(\\sum_{i=1}^n e_i\\dfrac{\\delta }{\\delta x_i})\\)\n\nAnd: \\(\\mathbf x\\times \\mathbf y=\\||\\mathbf x|| ||\\mathbf y|| \\sin(\\theta )\\mathbf n\\)\n\nThe curl of a vector field is another vector field.\n\nThe curl measures the rotation about a given point. For example if a vector field is the gradient of a height map, the curl is \\(0\\) at all points, however for a rotating body of water the curl reflects the rotation at a given point.\n\n\\subsection{Divergence of the curl}\n\nIf we have a vector field \\(\\mathbf F\\), the divergence of its curl is \\(0\\):\n\n\\(\\nabla . (\\nabla \\times \\mathbf F)=0\\)\n\n", "meta": {"hexsha": "ba1bbdca2beb7f9027c9f8e82a99d0635b35fe19", "size": 707, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/multiCalculus/04-01-curl.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/multiCalculus/04-01-curl.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/multiCalculus/04-01-curl.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1363636364, "max_line_length": 233, "alphanum_fraction": 0.6916548798, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9626731094431571, "lm_q2_score": 0.8807970701552505, "lm_q1q2_score": 0.8479196543147777}} {"text": "\\section{Polynomial functions}\nA very useful family of real functions can be derived using only three fundamental operations: addition, multiplication and exponentiation: the (real) \\emph{polynomial functions}. These are functions of the form\n\\begin{equation}\n\tP_{n}(x) = a_{0} + a_{1}x + a_{2}x^{2} + a_{3}x^{3} + \\cdots + a_{n}x^{n},\n\t\\label{eq:polynomial_function}\n\\end{equation}\nwhere $a_{0},a_{1},\\dots,a_{n}$ are real numbers called the \\emph{coefficients} of the polynomial function. Note that $a_{n}\\neq0$, i.e. the \\emph{degree} of the polynomial function is the index of the highest non-zero coefficient (and thus the highest power in the expression). We also call this the \\emph{order} of the polynomial function.\n\n\\begin{example}{Polynomial}{}\n\tThe following is a polynomial function of degree $n=6$:\n\t\\[\n\t\tP(x) = 4 + 2x - 3x^{2} + 7x^{4} - x^{5} + 3x^{6}.\n\t\\]\n\n\tBreaking down this polynomial to its constituent terms:\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\begin{tikzpicture}[node distance=15mm]\n\t\t\t\\node (P) {$P(x)=$};\n\t\t\t\\node[right of=P] (x0) {$4$};\n\t\t\t\\node[right of=x0] (x1) {$+2x$};\n\t\t\t\\node[right of=x1] (x2) {$-3x^{2}$};\n\t\t\t\\node[right of=x2] (x4) {$+7x^{4}$};\n\t\t\t\\node[right of=x4] (x5) {$-x^{5}$};\n\t\t\t\\node[right of=x5] (x6) {$+3x^{6}$};\n\t\t\t\n\t\t\t\\node[below of=x0] (a0) {$a_{0}=4$};\n\t\t\t\\node[below of=x1] (a1) {$a_{1}=2$};\n\t\t\t\\node[below of=x2] (a2) {$a_{2}=-3$};\n\t\t\t\\node[below of=x4] (a4) {$a_{4}=7$};\n\t\t\t\\node[below of=x5] (a5) {$a_{5}=-1$};\n\t\t\t\\node[below of=x6] (a6) {$a_{6}=3$};\n\n\t\t\t\\draw[arrow, thin] (x0) -- (a0);\n\t\t\t\\draw[arrow, thin] (x1) -- (a1);\n\t\t\t\\draw[arrow, thin] (x2) -- (a2);\n\t\t\t\\draw[arrow, thin] (x4) -- (a4);\n\t\t\t\\draw[arrow, thin] (x5) -- (a5);\n\t\t\t\\draw[arrow, thin] (x6) -- (a6);\n\t\t\\end{tikzpicture}\n\t\\end{figure}\n\n\tNote that $a_{3}$ is missing from the polynomial function (i.e. there is no $x^{3}$ term). This means that $a_{3}=0$.\n\\end{example}\n\nA shorthand way to write the general form of a polynomial function is by using the \\emph{summation notation}:\n\\begin{equation}\n\tP(x) = \\sum\\limits_{k=0}^{n}a_{k}x^{k}.\n\t\\label{eq:summation_notation}\n\\end{equation}\nThis notation, called the \\emph{Capital-sigma notation}, essentially represents addition of $n$ elements (in the case shown here), each with its own \\emph{index of summation}, in this case $i$. The most general form of the summation notation is\n\\begin{equation}\n\t\\sum\\limits_{i=k}^{n}a_{i} = a_{k} + a_{k+1} + a_{k+2} + \\cdots + a_{n-1} + a_{n},\n\t\\label{eq:summation_notation_general}\n\\end{equation}\ni.e. the notation tells us to add those elements $a_{i}$ for which $k\\geq i\\geq n$. Note that in the case of \\autoref{eq:summation_notation}, when $k=0,\\ x^{k}=x^{0}=1$ and the first term of the polynomial function has no $x$ power (i.e. it is simply $a_{0}$), and when $k=1,\\ x^{k}=x^{1}=x$ and thus the second term is $a_{1}x$. We will encounter the summation notation in more details later in the book.\n\nIn the special case $n=0$, i.e. when $P(x)=a_{0}$, the function is constant. When $n=1$ the function $P(x)=a_{0}+a_{1}x$ is a line, and when $n=2,\\ P(x)=a_{0}+a_{1}x+a_{2}x^{2}$ is a quadratic function.\n\n\\begin{example}{Polynomial functions for $n=0,1,2$}{special_polynomials}\n\tThe following graphs represent the polynomial functions of degrees $n=0,1,2$ with coefficients $a_{0}=2,\\ a_{1}=1,\\ a_{2}=\\frac{1}{2}$:\n\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\tikzset{flbl/.style={draw=#1, thick, fill=white, rounded corners}}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tgraph2d,\n\t\t\t\t\twidth=9cm, height=9cm,\n\t\t\t\t\txmin=-9, xmax=9,\n\t\t\t\t\tymin=-9, ymax=9,\n\t\t\t\t\tdomain=-9:9,\n\t\t\t\t\trestrict y to domain=-9:9,\n\t\t\t\t\tdeclare function={p0(\\x)=2;},\n\t\t\t\t\tdeclare function={p1(\\x)=2+\\x;},\n\t\t\t\t\tdeclare function={p2(\\x)=2+\\x+0.5*\\x^2;},\n\t\t\t\t]\n\t\t\t\t\\addplot[function, xred] {p0(x)} node[flbl=xred, below, pos=0.15, yshift=-1mm] {$P_{0}(x)=1$};\n\t\t\t\t\\addplot[function, xblue] {p1(x)} node[flbl=xblue, below, pos=0.1, rotate=45, yshift=-1mm] {$P_{1}(x)=1+x$};\n\t\t\t\t\\addplot[function, xgreen] {p2(x)} node[flbl=xgreen, right, pos=0.2, xshift=-3mm, yshift=5mm] {$P_{2}(x)=1+x+\\frac{1}{2}x^{2}$};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\\end{figure}\n\\end{example}\n\nThe values $x\\in\\mathbb{R}$ for which $P(x)=0$ are called the \\emph{roots} (also: \\emph{zeros}) of the polynomial function.\n\n\\begin{example}{Roots of a polynomial function}{}\n\tThe polynomial function $P(x) = 24x - 50x^{2} + 35x^{3} - 10x^{4} + x^{5}$ has the following $5$ roots: $x_{0}=0,\\ x_{1}=1,\\ x_{2}=2,\\ x_{3}=3,\\ x_{4}=4$. In the following graph of $P(x)$ the roots are shown as black dots.\n\t\\begin{figure}[H]\n\t\t\\centering\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\t\tgraph2d,\n\t\t\t\t\twidth=9cm, height=6cm,\n\t\t\t\t\txmin=-2, xmax=5,\n\t\t\t\t\tymin=-5, ymax=5,\n\t\t\t\t\tdomain=-2:5,\n\t\t\t\t\trestrict y to domain=-6:6,\n\t\t\t\t\tdeclare function={P(\\x)=\\x*(\\x-1)*(\\x-2)*(\\x-3)*(\\x-4);},\n\t\t\t\t]\n\t\t\t\t\\addplot[function, xred] {P(x)};\n\t\t\t\t\\addplot[black, only marks, mark=*, samples at={0,1,...,4}] {P(x)};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\\end{figure}\n\\end{example}\n\nThe maximum number of \\textbf{real} roots of a polynomial function with degree $n\\geq1$ is $n$, e.g. a polynomial of degree $n=4$ has at most $4$ real roots. This statement is a consequence of a very important theorem called \\emph{the fundamental theorem of algebra}, which due to its importance we will mention here without proof:\n\n\\begin{theorem}{The fundamental theorem of algebra}{fundamental}\n\tFor any $n\\geq1$, the polynomial function $P(z)=a_{0}+a_{1}z+a_{2}z^{2}+\\cdots+a_{n}z^{n}$, where $a_{0},a_{1},a_{2},\\dots,a_{n}$ are all \\textbf{complex numbers} and $a_{n}\\neq0$, has $n$ complex roots.\n\\end{theorem}\n\nGiven a polynomial function $P(x)$ with $n$ roots $r_{1},\\ r_{2},\\ \\cdots,\\ r_{n}$, the function can be written as a product of terms of the form $x-r_{i}$ (up to a constant), e.g. the polynomial function of degree $n=3$ with roots $-1,1,2$ can be written as\n\\begin{equation}\n\tP(x) = (x+1)(x-1)(x-2) = x^{3}-2x^{2}-x+2.\n\t\\label{eq:roots_form}\n\\end{equation}\n\n\\begin{example}{Higher order polynomial functions}{high_order_polynomials}\n\tThe following are the graphs of high-order polynomial functions ($n=3,4,5,6$):\n\n\t\\begin{figure}[H]\n\t\t\\captionsetup[subfigure]{labelformat=empty}\n\t\t\\centering\n\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tgraph2d,\n\t\t\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\t\t\txmin=-3, xmax=3,\n\t\t\t\t\t\tymin=-3, ymax=3,\n\t\t\t\t\t\tdomain=-3:3,\n\t\t\t\t\t\trestrict y to domain=-3:3,\n\t\t\t\t\t\tdeclare function={P3(\\x)=\\x^3-\\x^2-\\x;},\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot[function, xred] {P3(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{\\textcolor{xred}{$\\bm{x^{3}-x^{2}-x}$}}\n\t\t\\end{subfigure}\n\t\t\\hfill\n\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tgraph2d,\n\t\t\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\t\t\txmin=-3, xmax=3,\n\t\t\t\t\t\tymin=-3, ymax=3,\n\t\t\t\t\t\tdomain=-3:3,\n\t\t\t\t\t\trestrict y to domain=-10:10,\n\t\t\t\t\t\tdeclare function={P4(\\x)=\\x^4-3*\\x^2+\\x+1;},\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot[function, xblue] {P4(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{\\textcolor{xblue}{$\\bm{x^{4}-3x^{2}+x+1}$}}\n\t\t\\end{subfigure}\n\n\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tgraph2d,\n\t\t\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\t\t\txmin=-5, xmax=5,\n\t\t\t\t\t\tymin=-5, ymax=5,\n\t\t\t\t\t\tdomain=-5:5,\n\t\t\t\t\t\trestrict y to domain=-10:10,\n\t\t\t\t\t\tdeclare function={P5(\\x)=0.03*(\\x^5+3*\\x^4-11*\\x^3-27*\\x^2+10*\\x+24);},\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot[function, xgreen] {P5(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{\\textcolor{xgreen}{$\\bm{\\frac{3}{100}\\left( x^{5}+3x^{4}-11x^{3}-27x^{2}+10x+24 \\right)}$}}\n\t\t\\end{subfigure}\n\t\t\\hfill\n\t\t\\begin{subfigure}[b]{0.475\\textwidth}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tgraph2d,\n\t\t\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\t\t\txmin=-5, xmax=5,\n\t\t\t\t\t\tymin=-5, ymax=5,\n\t\t\t\t\t\tdomain=-5:5,\n\t\t\t\t\t\trestrict y to domain=-15:15,\n\t\t\t\t\t\tdeclare function={P6(\\x)=0.01*(x^6-x^5-26*x^4+15*x^3+150*x^2-25*x-5);},\n\t\t\t\t\t]\n\t\t\t\t\t\\addplot[function, xpurple] {P6(x)};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{\\textcolor{xpurple}{$\\bm{\\frac{1}{100}\\left( x^{6}-x^{5}-26x^{4}+15x^{3}+150x^{2}-25x-5\\right)}$}}\n\t\t\\end{subfigure}\n\t\\end{figure}\n\\end{example}\n\nAs can be seen in \\autoref{:high_order_polynomials}, the maximal number of `bends' in a polynomial function of order $n$ is $n-1$ (i.e. one less than the order of the function).\n\nWe will continue to explore polynomial functions in more details in future chapters.\n", "meta": {"hexsha": "035daca9d093bfd4aedc507edc5d0a2cc9c8b010", "size": 8445, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/intro/polynomials.tex", "max_stars_repo_name": "JASory/maths_book", "max_stars_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2021-12-25T20:02:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T17:57:59.000Z", "max_issues_repo_path": "chapters/intro/polynomials.tex", "max_issues_repo_name": "JASory/maths_book", "max_issues_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2022-01-17T05:01:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-20T06:18:24.000Z", "max_forks_repo_path": "chapters/intro/polynomials.tex", "max_forks_repo_name": "JASory/maths_book", "max_forks_repo_head_hexsha": "b5fdd19b09e97697f287f5ca83e0d9133b704789", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2022-01-17T10:15:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T10:45:13.000Z", "avg_line_length": 41.3970588235, "max_line_length": 405, "alphanum_fraction": 0.6277087034, "num_tokens": 3284, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.9196425273236, "lm_q1q2_score": 0.8478385262009079}} {"text": "\\paragraph{Mean} \\hspace{0pt}\n\n\\vspace{-20pt}\n\\begin{gather*}\n\\mean = \\frac{1}{n}\\sum_{i=1}^n X_i\n\\end{gather*}\n\n\\paragraph{Mean for grouped data} \\hspace{0pt}\n\n\\vspace{-5pt}\n\\begin{gather*}\n\\mean = \\frac{1}{n}\\sum_{i=1}^n n_i x_i\n\\end{gather*}\n\nwhere $n_i$ is count of $i$th result values, and $x_i$ is the $i$th result value.\n\n%\\paragraph{Weighted mean} \\nodata\n\n\\paragraph{Median} \\hspace{0pt}\n\n\\vspace{-20pt}\n\\begin{gather*}\n\\med = \\frac{1}{2} \\left( X_{\\lfloor \\frac{n+1}{2} \\rfloor : n} + X_{\\lceil \\frac{n+1}{2} \\rceil : n} \\right) =\\\\ \n= \\begin{cases}\n X_{\\frac{n+1}{2} : n} \\mbox{ if } n \\mbox{ is odd} \\\\\n \\frac{1}{2} \\left( X_{\\frac{n}{2} : n} + X_{\\frac{n+2}{2} : n} \\right) \\mbox{ if } n \\mbox{ is even}\n\\end{cases}\n\\end{gather*}\n\nwhere $x_{k:n}$ is the $k$th sample element taken from sorted sample.\n\n\\paragraph{Weighted median}\n\\begin{gather*}\n\\med = X_{\\med}^L + \\frac{b}{n_{\\med}} \\left( \\frac{n}{2} - \\sum_{i=1}^{i_{\\med}-1} n_i \\right)\n\\end{gather*}\n\n\\paragraph{Mode}\nis an observation that appears most often.\n\n\\paragraph{Trimmed mean} \\hspace{0pt}\n\n\\vspace{-5pt}\n\\begin{gather*}\n\\mean_{t,k} = \\frac{1}{n - 2k} \\sum_{i=k+1}^{n-k} X_i\n\\end{gather*}\n\n\\paragraph{Winsorized mean}\nis thought to decrease the effect of outliers.\n\\begin{gather*}\n\\mean_{w,k} = \\frac{1}{n} \\left[ (k+1)X_{k+1} + \\sum_{i=k+2}^{n-k-1} + (k+1)X_{n-k} \\right]\n\\end{gather*}\n\n\\paragraph{Geometrical mean}\n\n\\[ \\mean_g = \\sqrt[n]{x_1 x_2 \\ldots x_n} \\]\n\n\\paragraph{Harmonic mean} \\hspace{0pt}\n\n\\vspace{-10pt}\n\\[ \\mean_h = \\frac{1}{ \\frac{1}{n} \\sum_{i=1}^n \\frac{1}{X_i} } \\]\n", "meta": {"hexsha": "4ca5a60ecb25be1d6f11943e7364f6fcb418906e", "size": 1565, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cs_2b_measures_central.tex", "max_stars_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_stars_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cs_2b_measures_central.tex", "max_issues_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_issues_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cs_2b_measures_central.tex", "max_forks_repo_name": "mbdevpl/wut-bsc-computer-statistics-formulas", "max_forks_repo_head_hexsha": "ce5febce6f6fc680c445257ca263962a0a76a688", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6557377049, "max_line_length": 114, "alphanum_fraction": 0.6230031949, "num_tokens": 668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951588871157, "lm_q2_score": 0.9073122132152183, "lm_q1q2_score": 0.8477881396274545}} {"text": "\n\\subsection{Information}\n\n\\subsubsection{Criteria}\n\nSelf information measures surprise of outcome. also called a surprisal.\n\nWhen we observe an outcome we get information. We can develop a measure for how much information is associated with a specific measurement.\n\nRule 1: Information is always positive\n\nRule 2: If \\(P(x)=1\\), the the information for \\(I(P(x))=0\\).\n\nRule 3: If two events are independent, then their information is additive.\n\n\\begin{itemize}\n\\item \\(P(C)=P(A)P(B)\\)\n\\item \\(I(P(C))=I(P(A)P(B))\\)\n\\item \\(I(P(A))+I(P(B))=I(P(A)P(B))\\)\n\\end{itemize}\n\n\\subsubsection{Choice of function}\n\nA function which satisifes this is \\(I(P(A))=-\\log(P(A))\\)\n\nAny base can be used. 2 is most common, information is in units of bit then.\n\n", "meta": {"hexsha": "08f2bcc754d97be5fdf1fe912909ee71d7f4c1f0", "size": 743, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/probability/entropy/01-01-information.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/probability/entropy/01-01-information.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/probability/entropy/01-01-information.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5357142857, "max_line_length": 139, "alphanum_fraction": 0.7079407806, "num_tokens": 213, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9643214532237354, "lm_q2_score": 0.8791467564270272, "lm_q1q2_score": 0.8477800777546443}} {"text": "\\subsection{Product Rule}\r\n\\begin{lemma}\r\n\tLet $f$ and $g$ be differentiable functions. Then\r\n\t\\begin{equation}\r\n\t\t(fg)^\\prime = fg^\\prime + gf^\\prime.\r\n\t\\end{equation}\r\n\\end{lemma}\r\n\\begin{proof}\r\n\tApplying the definition of the derivative and limit properties,\r\n\t\\begin{align*}\r\n\t\t(fg)^\\prime &= \\lim_{h \\to 0}{\\frac{f(x+h)g(x+h) - f(x)g(x)}{h}} \\\\\r\n\t\t&= \\lim_{h \\to 0}{\\frac{f(x+h)g(x+h)-f(x+h)g(x)+f(x+h)g(x)-f(x)g(x)}{h}} \\\\\r\n\t\t&= \\lim_{h \\to 0}{\\frac{f(x+h)\\left(g(x+h)-g(x)\\right)}{h}} + \\lim_{h \\to 0}{\\frac{g(x)\\left(f(x+h)-f(x)\\right)}{h}} \\\\\r\n\t\t&= \\lim_{h \\to 0}{f(x+h)} \\lim_{h \\to 0}{\\frac{g(x+h)-g(x)}{h}} + g(x)\\lim_{h \\to 0}{\\frac{f(x+h)-f(x)}{h}} \\\\\r\n\t\t&= fg^\\prime + gf^\\prime\r\n\t\\end{align*}.\r\n\\end{proof}\r\n\r\n\\begin{example}\r\n\tGiven the the derivative of $\\sin{(x)}$ is $\\cos{(x)}$, find the derivative of $x^2\\sin{(x)}$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tUsing the product rule and power rule,\r\n\t\\begin{equation*}\r\n\t\tf^\\prime(x) = x^2\\cos{(x)} + \\sin{(x)}2x.\r\n\t\\end{equation*}\r\n\\end{answer}", "meta": {"hexsha": "d1e09a72eaa24d6a12306f2963549ba416062d00", "size": 1008, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/derivatives/derivative_rules/product_rule.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/derivatives/derivative_rules/product_rule.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/derivatives/derivative_rules/product_rule.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 37.3333333333, "max_line_length": 122, "alphanum_fraction": 0.5654761905, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810496235896, "lm_q2_score": 0.8947894569842487, "lm_q1q2_score": 0.8477065749498593}} {"text": "%\\newbreak\n\\section{KL divergence and cross-entropy}\nCross-entropy minimization is frequently used in optimization and rare-event probability estimation. When comparing a distribution against a fixed reference distribution, cross-entropy and KL divergence are identical up to an additive constant. See more details in \\cite{murphy2012machine,kullback1951information,kullback1997information} and the reference therein.\n\nThe KL(Kullback--Leibler) divergence defines a special distance between two discrete probability distributions \n$$\np=\\left( \\begin{array}{ccc}\np_1\\\\\n\\vdots \\\\\np_k\n\\end{array} \\right),\\quad q=\\left( \\begin{array}{ccc}\nq_1\\\\\n\\vdots \\\\\nq_k\n\\end{array} \\right)\n$$\nwith $0\\le p_i, q_i\\le1$ and $\\sum_{i=1}^{k}p_i=\\sum_{i=1}^{k}q_i=1$ by\n\\begin{equation}\n\\label{KL-divergence}\nD_{\\rm KL}(q,p)= \\sum_{i=1}^k q_i\\log \\frac{q_i}{p_i}. \n\\end{equation}\n\n\\begin{lemma}\\mbox{}\n$D_{\\rm KL}(q,p)$ works like a ``distance\" without the symmetry:\n\t\\begin{enumerate}\n\t\t\\item $D_{\\rm KL}(q,p)\\ge0$;\t\t\n\t\t\\item $D_{\\rm KL}(q,p)=0$ if and only if $p=q$;\n\t\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}We first note that the elementary inequality\n\t\\begin{equation}\n\t\\log x \\le x - 1, \\quad\\mathrm{for\\ any\\ }x\\ge0,\n\t\\end{equation}\n\tand the equality holds if and only if $x=1$.\n\t\\begin{equation}\n\t-D_{\\rm KL}(q,p) = - \\sum_{i=1}^c q_i\\log \\frac{q_i}{p_i} = \\sum_{i=1}^k q_i\\log \\frac{p_i}{q_i} \\le \\sum_{i=1}^k q_i( \\frac{p_i}{q_i} - 1) = 0.\n\t\\end{equation}\n\tAnd the equality holds if and only if \n\t\\begin{equation}\n\t\\frac{p_i}{q_i} = 1 \\quad \\forall i = 1:k.\n\t\\end{equation}\n\\end{proof}\n\nDefine cross-entropy for distribution $p$ and $q$ by\n\\begin{equation}\\label{Cross-Entropy}\nH(q,p) = - \\sum_{i=1}^k q_i \\log p_i,\n\\end{equation}\nand the entropy for distribution $q$ by \n\\begin{equation}\\label{Entropy}\nH(q) = - \\sum_{i=1}^k q_i \\log q_i.\n\\end{equation}\nNote that\n\\begin{equation}\nD_{\\rm KL}(q,p)= \\sum_{i=1}^k q_i\\log \\frac{q_i}{p_i} = \\sum_{i=1}^k q_i \\log q_i - \\sum_{i=1}^k q_i \\log p_i\n\\end{equation}\nThus, \n\\begin{equation}\\label{KLandEntropy}\nH(q,p) = H(q) + D_{\\rm KL}(q,p).\n\\end{equation} \nIt follows from the relation \\eqref{KLandEntropy} that\n\\begin{equation}\n\\label{EntropyandKL}\n\\mathop{\\arg\\min}_p D_{\\rm KL}(q,p)=\\mathop{\\arg\\min}_p H(q,p).\n\\end{equation}\n\nThe concept of cross-entropy can be used to define a loss function in machine learning and optimization. \nLet us assume $y_i$ is the true label for $x_i$, for example $y_i = e_{k_i}$ if $x_i \\in A_{k_i}$. Consider the predicted distribution \n\\begin{equation}\\label{key}\n\\bm p(x; \\bm \\theta) = \\frac{1}{\\sum\\limits_{i=1}^k e^{w_i x+b_i}}\n\\begin{pmatrix}\ne^{w_1 x+b_1}\\\\\ne^{w_2 x+b_2}\\\\\n\\vdots\\\\\ne^{w_k x+b_k}\n\\end{pmatrix}\n= \\begin{pmatrix}\np_1(x; \\bm\\theta) \\\\\np_2(x; \\bm\\theta) \\\\\n\\vdots \\\\\np_k(x; \\bm\\theta)\n\\end{pmatrix}\n\\end{equation}\nfor any data $x \\in A$.\nBy \\eqref{EntropyandKL}, the minimization of KL divergence is equivalent to the minimization of the cross-entropy, namely\n\\begin{equation}\n\\mathop{\\arg\\min}_{\\theta} \\sum_{i=1}^N D_{\\rm KL}(y_i,\\bm p(x_i; \\bm \\theta)) = \\mathop{\\arg\\min}_{\\theta} \\sum_{i=1}^N H(y_i, \\bm p(x_i; \\bm \\theta)).\n\\end{equation} \nRecall that we have all data $D = \\{(x_1,y_1),(x_2,y_2),\\cdots, (x_N, y_N)\\}$. Then, it is natural to consider the \nloss function as following:\n\\begin{equation}\n\\sum_{j=1}^N H(y_i, \\bm p(x_i; \\bm \\theta)),\n\\end{equation}\nwhich measures the distance between the real label and predicted one for all data.\nIn the meantime, we can check that\n\\begin{equation}\n\\begin{aligned}\n\\sum_{j=1}^N H(y_j, \\bm p(x_j; \\bm \\theta))&=-\\sum_{j=1}^N y_j \\cdot \\log \\bm p(x_j; \\bm \\theta )\\\\\n&=-\\sum_{j=1}^N \\log p_{i_j}(x_i; \\bm \\theta) \\quad (\\text{because}~y_j = e_{i_j}~\\text{for}~x_j \\in A_{i_j})\\\\\n&=-\\sum_{i=1}^k \\sum_{x\\in A_i} \\log p_{i}(x; \\bm \\theta) \\\\\n&=-\\log \\prod_{i=1}^k \\prod_{x\\in A_i} p_{i}(x; \\bm \\theta)\\\\\n& = L(\\theta)\n\\end{aligned}\n\\end{equation}\nwith $L(\\theta)$ defined in \\eqref{logistic} as \n\\begin{equation}\nL(\\bm \\theta) = - \\sum_{i=1}^k \\sum_{x\\in A_i} \\log p_{i}(x;\\bm \\theta).\n\\end{equation}\n\nThat is to say, the logistic regression loss function defined by likelihood in \\eqref{logistic} is exact\nthe loss function defined by measuring the distance between real label and predicted one via cross-entropy.\nWe can note \n\\begin{equation}\\label{key}\n\\min_{\\bm \\theta} L_\\lambda(\\bm \\theta) \\Leftrightarrow \\min_{\\bm \\theta} \\sum_{j=1}^N H(y_i, \\bm p(x_i; \\bm \\theta)) + \\lambda R(\\|\\bm \\theta\\|) \n\\Leftrightarrow \\min_{\\bm \\theta} \\sum_{j=1}^N D_{\\rm KL}(y_i, \\bm p(x_i; \\bm \\theta)) + \\lambda R(\\|\\bm \\theta\\|).\n\\end{equation}\n\n\n\n\\endinput", "meta": {"hexsha": "c4b5497678d03ea2378a98c46fe5d9751e4dd618", "size": 4602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6DL/KL-CR-LR.tex", "max_stars_repo_name": "liuzhengqi1996/math452", "max_stars_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "6DL/KL-CR-LR.tex", "max_issues_repo_name": "liuzhengqi1996/math452", "max_issues_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6DL/KL-CR-LR.tex", "max_forks_repo_name": "liuzhengqi1996/math452", "max_forks_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.35, "max_line_length": 367, "alphanum_fraction": 0.6760104302, "num_tokens": 1791, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067211996142, "lm_q2_score": 0.899121377945727, "lm_q1q2_score": 0.8474279418881062}} {"text": "\n\n\\section{ Gradient descent's algorithm }\n\\subsection{Introduction}\n\nGradient descent is a general technique for minimizing differentiable functions through its slope. \\cite{LFD}\nIt is used to find local minimums. The start point is crucial in the search. \n\nThe basic idea is to update the weights using the gradients until it is not possible to continuous minimizing the error.\n\n\n\\medskip\n\n\\subsection{Math}\n\nIn order to understand the algorithm we are going to define: \n\nLet $w(0) \\in \\mathbb{R}^d$ be an arbitrary initial point,\n$E : \\mathbb{R}^d \\times \\mathbb{R}^d \\longrightarrow \\mathbb R$\na differentiable function. The learning rate or step size $\\eta \\in \\mathbb{R}^+$\nis a experimental coefficient about how much are we going to follow the slope to obtain the new weight. \nLet $w(t) \\in \\mathbb{R}^d \\quad t \\in \\mathbb N$ be the weight for $t$ iteration which is defined as\n\n\\begin{equation*}\n w(t+1) = w(t) - \\eta \\nabla E_{in}(w(t))\n\\end{equation*}\n\n\\subsubsection{ Properties}\n\n\\begin{itemize}\n\\item This algorithm gives local minimums.\n\\item Convergence is not assured in a finite time, so it would be necessary some stop criteria. \n\\item For a convex function it would be a unique global minimum.\n\\item The convergence success (in time) depends on the learning rate, $\\eta$. \n\\end{itemize}\n\n\n\\subsection{Algorithm}\n\nThe following code snippet implements the algorithm, where $w(0)$ is the $\\texttt{initial\\_point}$, $E$ is the error, $\\nabla E_{in}(w)$\nis $\\texttt{gradient\\_function}$ and\nfinally $\\eta$ is $eta.$ The value $\\eta = 0.1$ is a heuristic based on purely practical observation \\cite{LFD}.\n\n\nIn order to avoid an infinite search, our stop criteria are a limit in the number of iterations $\\texttt{max\\_iter}$ and an error tolerance. \n\n\\begin{minted}{python} \n\n def gradient_descent(initial_point, loss_function,\n gradient_function, eta, max_iter, target_error):\n '''\n initicial point: w_0 \n E: error function \n gradient_function\n eta: step size \n\n ### stop conditions ###\n max_iter\n target_error\n\n #### return ####\n (w,iterations)\n w: the coordenates that minimize E\n it: the numbers of iterations needed to obtain w\n \n '''\n\n iterations = 0\n error = E( initial_point[0], initial_point[1])\n w = initial_point\n \n while ( (iterations < max_iter) and(error > target_error)): \n\n w = w - eta * gradient_function(w[0], w[1])\n \n iterations += 1\n error = loss_function(w[0], w[1])\n \n \n return w, iterations\n \n\\end{minted}\n\n\\subsection{Problem 1}\n\nWe want to solve the following problem: %\\\\\n\nUse gradient descent's algorithm to find a minimum for the\nfunction\n\n\n\\[E(u,v) = (u^3 e^{(v-2)} - 2* v^2 e^{-u})^2.\\]\n\nSet $(u,v)=(1,1)$ as initial point and use learning rate $\\eta = 0.1$.\n\n\\subsubsection{Compute analytically the gradient of $E(u,v)$}\n\n\n\\begin{multline*}\n \\nabla E(u,v) = \\left( \\frac{\\partial}{\\partial u}(u^3 e^{(v-2)} - 2* v^2 e^{-u})^2 , \\frac{\\partial}{\\partial v} (u^3 e^{(v-2)} - 2 v^2 e^{-u})^2 \\right) = \\\\\n = \\left(2(u^3 e^{(v-2)} - 2* v^2 e^{-u})(3u^2e^{(v-2)} + 2 v^2 e^{-u} ), 2(u^3 e^{(v-2)} - 2* v^2 e^{-u})(u^3 e^{(v-2)} - 4 v e^{-u}) \\right)\n\\end{multline*}\n\n\n\\subsubsection{Number of iterations and final coordinates.}\n\nFirstable we need to use 64-bits float, so we are going to use the data type $float64$ of numpy library \\cite{float64}.\n\nThe functions' declaration are:\n\n\\begin{minted}{python}\n def dEu(u,v):\n '''\n Partial derivate of E with respect to the variable u\n '''\n return np.float64(\n 2\n *( 3* u**2 * np.e**(v-2) + 2*v**2 * np.e**(-u) )\n *( u**3 * np.e**(v-2) - 2*v**2 * np.e**(-u))\n )\n \ndef dEv(u,v):\n '''\n Partial derivate of E with respect to the variable v\n '''\n return np.float64(\n 2*\n ( u**3 * np.e**(v-2) - 2*v**2 * np.e**(-u) )\n *( u**3 * np.e**(v-2) - 4*v * np.e**(-u))\n )\n\n\ndef gradE(u,v):\n ''' \n gradient of E\n '''\n return np.array([dEu(u,v), dEv(u,v)])\n\n\\end{minted}\n\nTo obtain the number of iterations and the final coordinates, the only thing we need to do is to call $\\texttt{gradien\\_descent}$ function with the initial conditions:\n\n\\begin{minted}{python}\neta = 0.01 \nmax_iter = 10000000000\ntarget_error = 1e-14\ninitial_point = np.array([1.0,1.0])\nw, it = gradient_descent( initial_point,\n E,\n gradE,\n eta,\n max_iter,\n target_error )\n\\end{minted}\n\nThe results are:\n\n\\begin{itemize}\n\\item Numbers of iterations: $178.$\n\\item Final coordinates: $( 1.162 , 0.924 ).$\n\\end{itemize}\n\nA 3d graph with the result is \n\n\\includegraphics[width=\\linewidth]{1_graph.png}\n\n\n\n\\subsection{Problem 2}\n\n\nLet's define the function $f(x,y) = (x+2)^2 + 2(y-2)^2 + 2 \\sin (2 \\pi x) \\sin (2 \\pi y)$.\n\n\\subsubsection{ Use gradient descent to minimize $f$}\n\nThe initial point is $(x_0 = -1, y_0 = 1)$,\nlearning rate is $\\eta = 0.01$ and the maximum number of iterations must\nbe $50$. Plot the result and repeat the experiment with $\\eta = 0.1$. \n\nFirstly we are going to calculate partial derivatives and gradient of $f$.\n\n\\begin{equation*}\n \\frac{\\partial }{\\partial x} f = 2 (x + 2) + 2 \\sin (2 \\pi y) \\cos ( 2 \\pi x) 2 \\pi = 2 (x + 2) + 4 \\pi \\sin (2 \\pi y) \\cos ( 2 \\pi x) \n\\end{equation*}\n\n\\begin{equation*}\n \\frac{\\partial }{\\partial y} f = 4 (y - 2) + 4 \\pi \\sin (2 \\pi x) \\cos ( 2 \\pi y) \n\\end{equation*}\n\n\nIt is important to realise that $f(x,y) <0$ for some values in $\\mathbb R^3$ so the error target has been omitted in this algorithm. \n\n\nNow the new algorithm is\n\\begin{minted}{python}\n def gradient_descent_trace(initial_point, loss_function,\n gradient_function, eta, max_iter):\n '''\n initicial point: w_0 \n loss_function: error function \n gradient_function\n eta: step size \n\n ### stop conditions ###\n max_iter\n\n #### return ####\n (w,iterations)\n w: the coordenates that minimize loss_function\n it: the numbers of iterations needed to obtain w\n \n '''\n\n iterations = 0\n error = loss_function( initial_point[0], initial_point[1])\n w = [initial_point]\n \n while iterations < max_iter: \n\n new_w = w[-1] - eta * gradient_function(w[-1][0], w[-1][1])\n \n \n iterations += 1\n error = loss_function(new_w[0], new_w[1])\n w.append( new_w ) \n \n return w, iterations\n \n \\end{minted}\n\n\n After 50 iterations for $\\eta = 0.01$, the final coordinates are $(-1.269, 1.287)$ and their value is $-0.381$. The graph which shows the relation between iterations and the function minimization is\n\n\n \\includegraphics[width=\\linewidth]{1_3_smaller_eta}\n\n As far as we have seen, before the $10^{th}$ iteration we are really close to the minimum and stay there without fluctuating.\n\n On the other hand, after 50 iterations for $\\eta = 0.1$ the final coordinate is $(-2.939, 1.608)$ and its value is $f(-2.939, 1.608) = 0.724$, so as we can see, this result is worse than the last one.\n\n In the following graph we can see how the images' value fluctuates iteration by iteration. \n\n \\includegraphics[width=\\linewidth]{1_3_bigger_eta}.\n\n The reason for this irregularity is that the step size is too big, so it skips the minimum.\n\n We can also compare the two experiment in the following graph.\n \n\\includegraphics[width=\\linewidth]{1_3_comparation_eta}.\n\n\n Moreover, based on its mathematical proof, which use Taylor's series, we know that it should be small, but if it is too small the algorithm will never reach the minimum in time.\n\n Let's see a new example: now $\\eta = 10^{-14}$, after 50 iterations the final coordinates are $(-1, 1)$ and the value is $3$, so this new selection is even worse that the one with the bigger step's size, although it goes without oscillating. \n\n \\includegraphics[width=\\linewidth]{1_3_epsilon_eta}\n \n \\includegraphics[width=\\linewidth]{1_3_eta_and_smaller.png}\n \n As a conclusion, a priory, it is difficult to select a step's size value, each problem should have an appropriate one and the selection must be empirical. Even though some heuristic \\cite{LFD} tell that $\\eta = 0.01$ it is a good try. \n\n \n \n\n\\subsubsection{Minimum value }\n\n\nBefore running the algorithm is important to think about a good value for the learning rate $\\eta$. Based on the last section, $\\eta = 0.1$ is a good one. \n\n\nThe results are\n\n\\begin{center}\n \\begin{tabular}{ |c|c|c| }\n \\hline\n Initial point & Final coordinates & Final value \\\\ \n \\hline\n\n (-0.5 -0.5) & (-0.793 -0.126) & 9.125 \\\\\n(1 1) & (0.677 1.29) & 6.437 \\\\\n( 2.1 -2.1) & ( 0.149 -0.096 ) & 12.491 \\\\\n(-3 3) & (-2.7315 2.713) & -0.381 \\\\\n(-2 2) & (-2. 2.) & 0 \\\\\n \n \n \\hline\n\\end{tabular}\n\\end{center}\n\n\nThis example gives the idea that the local minimums found depend on the start point $w_0$ and a priory, unless we know some properties\nof the function such as convexity or monotony we are not able to assure that the minimum found is global.\n\n\nUnder a mathematical point of view, to study a function's monotony we need some more complex tools and conditions, such as solve equations; something that\nthe majority of times is impossible.\n\nFortunately, for the error functions such a the mean quadratic error, this is totally possible. \n\n\n\n\\subsection{ Final conclusion about finding global functions' minimum by gradient descent} \n\nTo sum up this first chapter, gradient descent's algorithm is a technique to minimize differentiable functions. It dramatically depends on the initial point and the learning rate. Moreover, it does not give global minimums unless the function is convex.\n\nThe computational cost of the function is $\\mathcal O (N i)$ where $N$ is the size of the data set and $i$ the maximum number of iterations.\n\nSome useful examples of functions that can be successfully mimimized with used this algorithm are the mean quadratic's error or the logistic's function.\n\n\n\n", "meta": {"hexsha": "f743b4692a8503314b472832844c8d47262d7f28", "size": 10022, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "practica1/memory/gradient_descent.tex", "max_stars_repo_name": "BlancaCC/aprendizaje-automatico", "max_stars_repo_head_hexsha": "3a1288b951ffcf1121ee43aa37efe2daf7a06450", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "practica1/memory/gradient_descent.tex", "max_issues_repo_name": "BlancaCC/aprendizaje-automatico", "max_issues_repo_head_hexsha": "3a1288b951ffcf1121ee43aa37efe2daf7a06450", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-04T14:03:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T14:03:37.000Z", "max_forks_repo_path": "practica1/memory/gradient_descent.tex", "max_forks_repo_name": "BlancaCC/aprendizaje-automatico", "max_forks_repo_head_hexsha": "3a1288b951ffcf1121ee43aa37efe2daf7a06450", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1217948718, "max_line_length": 257, "alphanum_fraction": 0.6608461385, "num_tokens": 2930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240194661944, "lm_q2_score": 0.9032942112597331, "lm_q1q2_score": 0.8474019962275265}} {"text": "\\subsection{Arc length}\n\nLet $g(t)$ be a function that draws a curve.\nThe arc length from $g(a)$ to $g(b)$ is given by\n$$\\int_a^b|g'(t)|\\,dt$$\nwhere $|g'(t)|$ is the length of the tangent vector at $g(t)$.\nThe integral sums over all of the tangent lengths to arrive at the total length\nfrom $a$ to $b$.\nFor example, let us measure the length of the following curve.\n\n{\\color{blue}\n\\begin{verbatim}\nxrange = (0,1)\nyrange = (0,1)\ndraw(x^2)\n\\end{verbatim}\n}\n\n\\begin{center}\n\\includegraphics[scale=0.2]{arc.png}\n\\end{center}\n\n\\noindent\nA suitable $g(t)$ for the arc is\n$$g(t)=(t,t^2),\\quad0\\le t\\le1$$\nHence one Eigenmath solution for computing the arc length is\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = t\ny = t^2\ng = (x,y)\ndefint(abs(d(g,t)),t,0,1)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{1}{2}\\;5^{1/2}+\\tfrac{1}{4}\\log(5^{1/2}+2)$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nfloat\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle 1.47894$\n\n\\bigskip\n\\noindent\nAs expected, the result is greater than $\\sqrt2\\approx1.414$,\nthe length of the\ndiagonal from $(0,0)$ to $(1,1)$.\n\n\\bigskip\n\\noindent\nThe result seems rather complicated given that we\nstarted with a simple parabola.\nLet us inspect $|g'(t)|$ to see why.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\ng\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle g=\\begin{bmatrix}t\\\\ t^2\\end{bmatrix}$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nd(g,t)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\begin{bmatrix}1\\\\ 2t\\end{bmatrix}$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nabs(d(g,t))\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle (4t^2+1)^{1/2}$\n\n\\bigskip\n\\noindent\nThe following script does a discrete computation of the arc length\nby dividing the curve into 100 pieces.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\ng(t) = (t,t^2)\nh(k) = abs(g(k/100.0) - g((k-1)/100.0))\nsum(k,1,100,h(k))\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle 1.47894$\n\n\\bigskip\n\\noindent\nAs expected, the discrete result matches the analytic result.\n\n\\bigskip\n\\noindent\nFind the length of the curve $y=x^{3/2}$ from the origin to\n$x=\\tfrac{4}{3}$.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = t\ny = x^(3/2)\ng = (x,y)\ndefint(abs(d(g,x)),x,0,4/3)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{56}{27}$\n\n\\bigskip\n\\noindent\nBecause of the way $t$ is substituted for $x$,\nthe following code yields the same result.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\ng = (t,t^(3/2))\ndefint(abs(d(g,t)),t,0,4/3)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{56}{27}$\n\n\\subsection{Line integrals}\nThere are two different kinds of line integrals,\none for scalar fields and one\nfor vector fields.\nThe following table shows how both are based on the calculation of\narc length.\n\n\\begin{center}\n\\begin{tabular}{|l|l|l|}\n\\hline\n& Abstract form\n& Computable form\n\\\\\n\\hline\n & &\\\\\nArc length\n& $\\displaystyle{\\int_C ds}$\n& $\\displaystyle{\\int_a^b |g'(t)|\\,dt}$\\\\\n & &\\\\\n\\hline\n & & \\\\\nLine integral, scalar field\n& $\\displaystyle{\\int_C f\\,ds}$\n& $\\displaystyle{\\int_a^b f(g(t))\\,|g'(t)|\\,dt}$\\\\\n& &\\\\\n\\hline\n & & \\\\\nLine integral, vector field\n& $\\displaystyle{\\int_C(F\\cdot u)\\,ds}$\n& $\\displaystyle{\\int_a^b F(g(t))\\cdot g'(t)\\,dt}$\\\\\n & & \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\n\\noindent\nFor the vector field form, the symbol $u$ is the unit tangent vector\n$$u=\\frac{g'(t)}{|g'(t)|}$$\nThe length of the tangent vector cancels with $ds$\nas follows.\n$$\\int_C(F\\cdot u)\\,ds\n=\\int_a^b\\bigg(F(g(t))\\cdot\\frac{g'(t)}{|g'(t)|}\\bigg)\\,\\bigg(|g'(t)|\\,dt\\bigg)\n=\\int_a^b F(g(t))\\cdot g'(t)\\,dt\n$$\n\n\\noindent\nEvaluate\n$$\\int_Cx\\,ds\\quad\\hbox{and}\\quad\\int_Cx\\,dx$$\nwhere $C$ is a straight line from $(0,0)$ to $(1,1)$.\n\n\\bigskip\n\\noindent\nWhat a difference the measure makes.\nThe first integral is over a scalar field and the second is over a vector field.\nThis can be understood when we recall that\n$$ds=|g'(t)|\\,dt\n$$\nHence for $\\int_Cx\\,ds$ we have\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = t\ny = t\ng = (x,y)\ndefint(x abs(d(g,t)),t,0,1)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\frac{1}{2^{1/2}}$\n\n\\bigskip\n\\noindent\nFor $\\int_Cx\\,dx$ we have\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = t\ny = t\ng = (x,y)\nF = (x,0)\ndefint(dot(F,d(g,t)),t,0,1)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{1}{2}$\n\n\\bigskip\n\\noindent\nThe following line integral problems are from\n{\\it Advanced Calculus, Fifth Edition} by Wilfred Kaplan.\n\n\\bigskip\n\\noindent\nEvaluate $\\int y^2\\,dx$ along the straight\nline from $(0,0)$ to $(2,2)$.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = 2t\ny = 2t\ng = (x,y)\nF = (y^2,0)\ndefint(dot(F,d(g,t)),t,0,1)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{8}{3}$\n\n\\bigskip\n\\noindent\nEvaluate $\\int z\\,dx+x\\,dy+y\\,dz$\nalong the path\n$x=2t+1$, $y=t^2$, $z=1+t^3$, $0\\le t\\le 1$.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nx = 2t+1\ny = t^2\nz = 1+t^3\ng = (x,y,z)\nF = (z,x,y)\ndefint(dot(F,d(g,t)),t,0,1)\n\\end{Verbatim}\n\n\\noindent\n$\\displaystyle \\tfrac{163}{30}$\n", "meta": {"hexsha": "37eaabc50f79216bd0229c80ad0dddc5e539f634", "size": 5016, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/line-integral.tex", "max_stars_repo_name": "franko/eigenmath", "max_stars_repo_head_hexsha": "3fca24d09686220e430108dac4864a192d138f13", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-01-27T02:41:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-02T19:05:49.000Z", "max_issues_repo_path": "doc/line-integral.tex", "max_issues_repo_name": "franko/eigenmath", "max_issues_repo_head_hexsha": "3fca24d09686220e430108dac4864a192d138f13", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-01-29T14:09:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-13T16:17:03.000Z", "max_forks_repo_path": "doc/line-integral.tex", "max_forks_repo_name": "franko/eigenmath", "max_forks_repo_head_hexsha": "3fca24d09686220e430108dac4864a192d138f13", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-01-27T02:38:38.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-27T02:38:38.000Z", "avg_line_length": 20.3902439024, "max_line_length": 80, "alphanum_fraction": 0.6744417863, "num_tokens": 1877, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533144915913, "lm_q2_score": 0.9086178926024029, "lm_q1q2_score": 0.8472437655634754}} {"text": "\\section{Matrix Factorization}\n\\begin{theo}\nIf Gaussian elimination can be performed on the linear system $Ax=b$ without row interchanges, then the matrix $A$ can be factored into the product of a lower-triangular maxtrix $L$ and an upper-triangular matrix $U$, that is $A=LU$, where $m_{ji}=a_{ji}^{(i)}/a_{ii}^{(i)}$\n\\[\nU=\n\\begin{pmatrix}\na_{11}^{(1)} & a_{12}^{(1)} & \\cdots & a_{1n}^{(1)} \\\\\n0 & a_{22}^{(2)} & \\ddots & \\vdots \\\\\n\\vdots & \\ddots & \\ddots & a_{n-1,n}^{(n-1)} \\\\\n0 & \\cdots & 0 & a_{nn}^{(n)}\n\\end{pmatrix}\n\\quad\nU=\n\\begin{pmatrix}\n1 & 0 & \\cdots & 0 \\\\\nm_{21} & \\ddots & \\ddots & \\vdots \\\\\n\\vdots & \\ddots & \\ddots & 0 \\\\\nm_{n1} & \\cdots & m_{n,n-1} & 1\n\\end{pmatrix}\n\\]\n\\end{theo}\n", "meta": {"hexsha": "c09e3a080b57f4f390f80ba6b7c570253a50b79f", "size": 884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Notes/sections/6.5_Matrix_factorization.tex", "max_stars_repo_name": "Iydon/NumericalAnalysisNotes", "max_stars_repo_head_hexsha": "ef1e37b97522fce9837142d242676fdd16e74712", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2018-11-08T15:48:13.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-02T10:07:33.000Z", "max_issues_repo_path": "Notes/sections/6.5_Matrix_factorization.tex", "max_issues_repo_name": "iydon/NumericalAnalysisNotes", "max_issues_repo_head_hexsha": "ef1e37b97522fce9837142d242676fdd16e74712", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Notes/sections/6.5_Matrix_factorization.tex", "max_forks_repo_name": "iydon/NumericalAnalysisNotes", "max_forks_repo_head_hexsha": "ef1e37b97522fce9837142d242676fdd16e74712", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1818181818, "max_line_length": 274, "alphanum_fraction": 0.4739819005, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9579122696813394, "lm_q2_score": 0.8840392725805822, "lm_q1q2_score": 0.8468320660851058}} {"text": "\\section{Vector and Matrix Derivatives}\n\\label{sec:derivatives}\n\nDerivatives involving matrices and vectors can look nonintuitive when the usual symbolic matrix notation is used, but can be derived handily when index notation is used. A very concise and helpful resource for this is \\citeasnoun{barnesmatrixdiff}. \n\n\n\\subsection{Jacobian}\nIt is particularly helpful to remember the Jacobian, which is the derivative of a function with respect of a vector. The Jacobian of some function $f: \\mathbb{R}^n \\rightarrow \\mathbb{R}^m$ is:\n\n\\begin{equation}\n\\frac{\\mathrm{d} \\mathbf{f}(\\mathbf{x})}{\\mathrm{d} \\mathbf{x}}=\\left[\\frac{\\partial \\mathbf{f}}{\\partial x_1}, \\hdots, \\frac{\\partial \\mathbf{f}}{\\partial x_n} \\right]=\\left[\\begin{array}{ccc}\n\\frac{\\partial f_1}{\\partial x_1} & \\hdots & \\frac{\\partial f_1}{\\partial x_n} \\\\\n\\vdots & \\vdots & \\vdots \\\\\n\\frac{\\partial f_m}{\\partial x_1} & \\hdots & \\frac{\\partial f_m}{\\partial x_n} \\\\\n\\end{array}\\right]\n\\end{equation}\n\nI enjoy writing the gradient $\\frac{\\mathrm{d}}{\\mathrm{d}\\mathbf{x}}$ as $\\nabla_\\mathbf{x}$. The relationships below can all be derived as applications of the Jacobian.\n\n\\begin{equation}\n\\begin{array}{l}\n\\nabla_\\mathbf{x} \\left(\\mathbf{u}^T\\mathbf{x}\\right) = \\left[\\frac{\\partial }{\\partial x_1}\\left(\\sum_i u_i x_i\\right),...,\\frac{\\partial }{\\partial x_n}\\left(\\sum_i u_i x_i\\right)\\right] = \\mathbf{u}^T\\\\\n\\\\\n\\nabla_\\mathbf{x} \\left(\\mathbf{x}^T\\mathbf{u}\\right) = \\left[\\frac{\\partial }{\\partial x_1}\\left(\\sum_i u_i x_i\\right),...,\\frac{\\partial }{\\partial x_n}\\left(\\sum_i u_i x_i\\right)\\right] = \\mathbf{u}^T\\\\\n\\\\\n\\nabla_\\mathbf{x} \\left(\\mathbf{x}^T\\mathbf{x}\\right) = \\left[\\frac{\\partial }{\\partial x_1}\\left(\\sum_i x_i^2\\right),...,\\frac{\\partial }{\\partial x_n}\\left(\\sum_i x_i^2\\right)\\right] = 2\\mathbf{x}^T\\\\\n\\\\\n\\nabla_\\mathbf{x} \\left(\\mathbf{Ax}\\right) = \\left[\n\\begin{array}{ccc} \n\\underbrace{\\frac{\\partial }{\\partial x_1}\\left(\\sum_i A_{1i} x_i\\right)}_{A_{11}} &...& \\underbrace{\\frac{\\partial }{\\partial x_n}\\left(\\sum_i A_{1i} x_i\\right)}_{A_1n}\\\\\n\\vdots&\\vdots&\\vdots\\\\\n\\underbrace{\\frac{\\partial }{\\partial x_1}\\left(\\sum_i A_{ni} x_i\\right)}_{A_{n1}} &...& \\underbrace{\\frac{\\partial }{\\partial x_n}\\left(\\sum_i A_{ni} x_i\\right)}_{A_{nn}}\\\\\n\\end{array}\\right] = \\mathbf{A}\n\\end{array}\n\\end{equation}\n\n\n\\subsection{Inverse Function Theorem}\n\\label{sec:inverse_function_theorem}\nThe inverse function theorem gives a sufficient condition for the invertibility of a function near some point in its domain. If the derivative $f'$ of a function $f$ is continuous and non-zero near some point $a$ within its domain, then the function is invertible near that point. If $b = f(a)$, then:\n\n\\begin{equation}\n\\frac{d\\left[f^{-1}(b)\\right]}{dx} = \\frac{1}{\\frac{df(a)}{dx}}\n\\end{equation}\n\nThat is, the derivative of the inverse function at a point $b=f(a)$ of the range, is the reciprocal of the derivative of the function near the point $a$ in the domain. This extends to multivariable calculus. Given a function $\\mathbf{f}: \\mathbf{x} \\rightarrow \\mathbf{y}$:\n\n\\begin{equation}\n\\nabla_\\mathbf{y}\\left[\\mathbf{f}^{-1}\\right] = \\left[\\nabla_\\mathbf{x} \\mathbf{f} \\right]^{-1}\n\\end{equation}\n\nIn words: the Jacobian of the inverse function at the point $\\mathbf{b} = \\mathbf{f}(\\mathbf{a})$ is the matrix inverse of the Jacobian of the function at the point $\\mathbf{a}$. The sufficient condition is that the Jacobian $\\nabla_\\mathbf{x}\\mathbf{f}$ is continuous and \\textit{nonsingular} near $\\mathbf{a}$.\n\n\\subsection{Critical Points}\nCritical points are points where the Jacobian does not have maximal rank. In case of a square Jacobian, this means that the Jacobian is singular. \n\n\\subsection{Differential Volume Element, Change of Variables}\nThe Jacobian is used when transforming between different coordinate systems. Consider a transformation $\\mathbf{x} = \\mathbf{H}(\\mathbf{y})$, then:\n\n\\begin{equation}\n\\mathrm{d}^n x = \\left|\\nabla_\\mathrm{y} \\mathbf{H} \\right| \\mathrm{d}^n y\n\\end{equation}\n\nAnd:\n\n\\begin{equation}\n\\int_\\mathbf{x} \\mathrm{d}^n\\mathbf{x} f(\\mathbf{x}) = \\int_\\mathbf{y} \\mathrm{d}^n\\mathbf{y} \\left|\\nabla_\\mathrm{y} \\mathbf{H} \\right| f(\\mathbf{H}(\\mathbf{y}))\n\\end{equation}\n\nAlternatively, if $\\mathbf{y} = \\mathbf{H}^{-1}(\\mathbf{x})$:\n\n \\begin{equation}\n \\begin{array}{rl}\n \\mathrm{d}^n y &= \\left|\\nabla_\\mathrm{x} \\mathbf{H}^{-1}(\\mathbf{x})\\right| \\mathrm{d}^n x\\\\\n &= \\left| \\left[ \\nabla_\\mathrm{y} \\mathbf{H}(\\mathbf{y}) \\right]^{-1} \\right| \\mathrm{d}^n x\\\\\n \\mathrm{d}^n x &= \\frac{1}{\\left| \\left[ \\nabla_\\mathrm{y} \\mathbf{H}(\\mathbf{y}) \\right]^{-1} \\right|} \\mathrm{d}^n y \n \\end{array}\n \\end{equation}\n\nThe Jacobian has to be nonsingular within the domain of integration. This implies that $\\mathbf{x}$ and $\\mathbf{y}$ have to have the same dimension. In the context of probability theory that sometimes requires artificially defining additional variables so that $\\mathbf{H}$ is bijective because the quantity of interest has lower dimension (for example, if you calculate the mean of a random variable). \n\n\\subsection{Hessian}\n\\label{sec:hessian}\n\nThe Hessian is the second derivative of a scalar valued function $f:\\mathbb{R}^{n} \\rightarrow \\mathbb{R}$ with respect to a vector, i.e. $\\nabla\\cdot\\nabla f$. The elements are $\\mathbf{H}(f)_{i,j} = \\frac{\\partial^2 f}{\\partial x_i\\partial x_j}$. \n\n\\begin{equation}\n\\mathbf{H}(f) = \\left[\\begin{array}{cccc}\n\\frac{\\partial^2f}{\\partial x_1^2}&\\frac{\\partial^2f}{\\partial x_1\\partial x_2} & \\hdots & \\frac{\\partial^2f}{\\partial x_1\\partial x_n}\\\\\n\\frac{\\partial^2f}{\\partial x_2\\partial x_1}&\\frac{\\partial^2f}{\\partial x_2^2} & \\hdots & \\frac{\\partial^2f}{\\partial x_1\\partial x_n}\\\\\n\\vdots & \\vdots & \\ddots & \\vdots \\\\\n\\frac{\\partial^2f}{\\partial x_n\\partial x_1}&\\frac{\\partial^2f}{\\partial x_n\\partial x_2} & \\hdots & \\frac{\\partial^2f}{\\partial x_n^2}\n\\end{array} \\right]\n\\end{equation}\n\nThe Hessian of a vector valued function $f:\\mathbb{R}^n \\rightarrow \\mathbb{R}^m$ is a third order tensor with elements $\\mathbf{H}(\\mathbf{f})_{i,j,k} = \\frac{\\partial^2 f_k}{\\partial x_i\\partial x_j}$.\n\n\\subsubsection{Testing Convexity}\nThe definiteness (cf. section \\ref{sec:definite}) of the Hessian is used to test convexity.\n\n\\begin{tabular}{ll}\n$\\mathbf{H}\\succeq 0$ & convex\\\\\n$\\mathbf{H}\\succ 0$ & strictly convex\\\\\n$\\mathbf{H}\\preceq 0$ & concave\\\\\n$\\mathbf{H}\\prec 0$ & strictly concave\\\\\n\\end{tabular}\n\nIf this holds at a point, the property is local (for example at a local maximum or minimum), and if it holds everywhere on the domain, then the property is global.\n\n", "meta": {"hexsha": "ebf0be422adf42df3badd1039dc5cd14798d1f2f", "size": 6572, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/sections/linalg_diff.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/sections/linalg_diff.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/sections/linalg_diff.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.7454545455, "max_line_length": 404, "alphanum_fraction": 0.7040474741, "num_tokens": 2261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951588871157, "lm_q2_score": 0.9059898127684335, "lm_q1q2_score": 0.8465524950518686}} {"text": "\\section{Norm and distance}\n\\subsection{Norm} \n\\textit{Euclidean norm} (or just norm) is\\\\\n$||x||= \\sqrt{x_1^2+x_2^2+...+x_n^2}= \\sqrt{x^Tx}$\\\\\n\\textbf{Properties}\\\\\n\\textbullet homogeneity: $||\\beta x|| = |\\beta ||x|||$\\\\\n\\textbullet triangle inequality: $||x + y|| \\leq ||x|| + ||y||$\\\\\n\\textbullet non negativity: $||x|| \\geq 0$\\\\\n\\textbullet definiteness: $||x|| = 0$ only if x = 0\\\\\n\\textit{positive definiteness} = non negativity + definiteness\\\\\n\\textbf{rms}(x) = $\\sqrt{\\frac{x_1^2+...+x_n^2}{n}} = \\frac{||x||}{\\sqrt{n}}$ \\\\\n\\textbf{Norm of block vectors}\n$||(a,b,c)|| = \\sqrt{||a||^2 + ||b||^2 + ||c||^2} = ||(||a||, ||b||, ||c||)||$\\\\\n\\textbf{Chebyshev inequality}\n% Todo \nTodo\n\\subsection{Distance}\n$\\textbf{dist}(a,b) = ||a - b||$\\\\\n\\textit{Triangle Inequality}: $||a - c|| = ||(a - b) + (b - c)|| \\leq ||a-b|| + ||b-c||$\\\\\n$z_j$ is the nearest neighbor of x if $||x-z_j|| \\leq ||x-z_i||, i=1,..,m$\\\\\n\n\\subsection{Standard Deviation}\nde-meaned vector: $\\tilde{x} = x - \\textbf{avg}(x)\\textbf{1}$\\\\\nstandard deviation: \\textbf{std}(x) = \\textbf{rms}($\\tilde{x}$) = $\\frac{||x - (\\textbf{1}^Tx/n)\\textbf{1}||}{\\sqrt{n}}$\\\\\n${\\textbf{rms}(x)}^2 = {\\textbf{avg}(x)}^2 + {\\textbf{std}(x)}^2$\\\\\nBy Chebyshev inequality, $|x_i - \\textbf{avg}(x)| \\geq \\alpha \\textbf{std}(x)$ is no more than $1/\\alpha^2$ (for \n$\\alpha$ > 1)\n\\textit{Cauchy–Schwarz inequality}: $|a^Tb| \\leq \\Vert a\\Vert \\Vert b \\Vert$\n\\subsection{Angle}\nangle between two nonzero vectors a, b defined as\\\\\n$\\angle(a,b) = arccos(\\frac{a^Tb}{\\Vert a \\Vert \\Vert b \\Vert})$\\\\\n$a^Tb = \\Vert a \\Vert \\Vert b \\Vert cos (\\angle(a,b))$\\\\\n\\textbf{Classification of angles}\\\\\n\n$\\theta = \\pi/2$: $a \\perp b$\\\\\n$\\theta = 0$: $a^Tb = \\Vert a \\Vert \\Vert b \\Vert$\\\\\n$\\theta = \\pi = 180^{\\circ}$ : $a^Tb = -\\Vert a \\Vert \\Vert b\\Vert$\\\\\n$\\theta \\leq \\pi/2 = 90^{\\circ} = a^Tb \\geq 0$\\\\\n$\\theta \\geq \\pi/2 = 90^{\\circ} = a^Tb \\leq 0$\\\\\n\\textbf{Correlation Coeficient}\n$\\rho = \\frac{\\tilde{a}^T\\tilde{b}}{\\Vert\\tilde{a}\\Vert\\Vert\\tilde{b}\\Vert}$\\\\\nWith $u = \\tilde{a}/\\textbf{std}(a)$ \\& $u = \\tilde{b}/\\textbf{std}(b)$, \\\\\n$\\rho = u^Tv/n$ where $\\Vert u \\Vert = \\Vert v \\Vert = n$\n\\subsection{Complexity}\n% Todo\nTodo\n", "meta": {"hexsha": "3728cacd68ca5a4323e37bba34503a0deaf15bdd", "size": 2173, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_stars_repo_name": "ksb25395/COT5615", "max_stars_repo_head_hexsha": "d3f9d9375597ea2b15404ae5f46d21d9073b8697", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_issues_repo_name": "ksb25395/COT5615", "max_issues_repo_head_hexsha": "d3f9d9375597ea2b15404ae5f46d21d9073b8697", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_forks_repo_name": "ksb25395/COT5615", "max_forks_repo_head_hexsha": "d3f9d9375597ea2b15404ae5f46d21d9073b8697", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.2340425532, "max_line_length": 122, "alphanum_fraction": 0.5766221813, "num_tokens": 934, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9609517061554855, "lm_q2_score": 0.880797085800514, "lm_q1q2_score": 0.8464034623767834}} {"text": "\\subsection{Determinants}\r\n\\noindent\r\nThe determinant of a matrix is a signed number that tells by how much the transformation represented by a matrix scales volumes in a space.\r\nThe number is negative if the space was ``flipped'' during a transformation.\r\nThe number is zero if the dimension of the output space is less than that of the input space.\\\\\r\n\r\n\\noindent\r\nThe determinant is only defined for square matrices. It's easiest to understand the definition of a determinant recursively.\r\n\\begin{align*}\r\n\t\\det{\\left[ a \\right]} &= \\lvert a \\rvert = a \\\\\r\n\t\\det{\\left[\r\n\t\t\\begin{array}{cc}\r\n\t\t\ta & b \\\\\r\n\t\t\tc & d\r\n\t\t\\end{array}\r\n\t\t\\right]} &= \\begin{array}{|cc|}\r\n\t\ta & b \\\\\r\n\t\tc & d\r\n\t\\end{array} = ad - bc.\r\n\\end{align*}\r\nWe can define $a_{ij}$ as the entry in the ith row and jth column of matrix $A$ and $A_{ij}$ as the adjudicate matrix, which is the matrix $A$ if row $i$ and column $j$ were removed. This allows us to write a general formula for the determinant.\r\n\\begin{definition}\r\n\t\\begin{equation*}\r\n\t\t\\det{A} = \\sum_{j=1}^{n}{\\left(-1\\right)^{i+j}a_{ij}A_{ij}} \\text{ (for fixed i)} = \\sum_{i=1}^{n}{\\left(-1\\right)^{i+j}a_{ij}A_{ij}} \\text{ (for fixed j)}\r\n\t\\end{equation*}\r\n\\end{definition}\r\n\\noindent\r\nThis formula allows us to use any row or column to calculate the determinant, which is especially useful if a certain row contains lots of 0's.\\\\\r\n\r\n\\noindent\r\nBelow are some properties of the determinant for some $n \\times n$ matrix $A$ and scalar $\\lambda$.\r\n\\begin{align*}\r\n\t\\det{I_n} &= 1 \\\\\r\n\t\\det{(A^T)} &= \\det{A} \\\\\r\n\t\\text{If $A$ is invertible, } \\det{(A^{-1})} &= \\frac{1}{\\det{A}} \\\\\r\n\t\\det{(\\lambda A)} &= \\lambda^n\\det{A} \\\\\r\n\t\\det{(AB)} &= \\det{A}\\det{B} \\\\\r\n\t\\text{If $A$ is triangular, } \\det{A} &= \\prod_{i=1}^{n}{a_{ii}}\r\n\\end{align*}\r\n\r\n\\begin{example}\r\n\tFind the determinant of the following 3 x 3 matrix.\r\n\t\\begin{equation*}\r\n\t\tA = \\begin{bmatrix}\r\n\t\t\t1 & 3 & 7 \\\\\r\n\t\t\t0 & 2 & -1 \\\\\r\n\t\t\t2 & 7 & 9\r\n\t\t\\end{bmatrix}\r\n\t\\end{equation*}\r\n\\end{example}\r\n\\noindent\r\nWe'll use the first column since it has only two non-zero entries.\r\n\\begin{equation*}\r\n\t\\begin{bmatrix}\r\n\t\t1 & 3 & 7 \\\\\r\n\t\t0 & 2 & -1 \\\\\r\n\t\t2 & 7 & 9\r\n\t\\end{bmatrix} = 1 \\text{ } \\begin{array}{|cc|}\r\n\t\t2 & -1 \\\\\r\n\t\t7 & 9\r\n\t\\end{array} + 2 \\text{ } \\begin{array}{|cc|}\r\n\t\t3 & 7 \\\\\r\n\t\t2 & -1\r\n\t\\end{array} = (18+7) + 2(-3-14) = -9.\r\n\\end{equation*}", "meta": {"hexsha": "47b4f21756f989e3640bd967ab82ce525225559c", "size": 2347, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "common/vectorsMatrices/determinants.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "common/vectorsMatrices/determinants.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "common/vectorsMatrices/determinants.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 36.1076923077, "max_line_length": 246, "alphanum_fraction": 0.6195142735, "num_tokens": 850, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9664104933824754, "lm_q2_score": 0.8757869916479466, "lm_q1q2_score": 0.8463697386964459}} {"text": "\\section{Parametric Inference}\n\nIn parametric inference, the quantity of interest might be some function $T(\\theta)$. The sought-after parameters are \\textit{parameters of interest} and additional parameters that emerge as part of the model are \\textit{nuisance parameters}. Parametric inference deals with creating parametric estimators.\n\n\\subsection{Method of Moments}\nThe method of moments relies on a system of linear equations to link estimators of moment to sample moments. The $j$th moment is given by:\n\n\\begin{equation}\n\\alpha_j = \\int x^j dF_{\\theta}(x)\n\\end{equation}\n\nThe $j$th sample moment is given by:\n\n\\begin{equation}\n\\hat{\\alpha}_j = \\frac{1}{n} \\sum_{i=1}^ n X_i^j\n\\end{equation}\n\n\nThe method of moments estimator $\\hat{\\theta}_n$ is defined to be the value of $\\theta$ so that:\n\n\\begin{equation}\n\\begin{array}{l}\n\\alpha_1(\\hat{\\theta}_n) = \\hat{\\alpha}_1\\\\\n\\alpha_2(\\hat{\\theta}_n) = \\hat{\\alpha}_2\\\\\n\\alpha_3(\\hat{\\theta}_n) = \\hat{\\alpha}_3\\\\\n\\alpha_4(\\hat{\\theta}_n) = \\hat{\\alpha}_4\\\\\n\\vdots\n\\end{array}\n\\end{equation}\n\nThe method of moments estimator satisfies:\n\n\\begin{enumerate}\n\\item The estimate $\\hat{\\theta}_n$ exists with probability tending to 1.\n\\item The estimate is consistent: $\\hat{\\theta}_n \\xrightarrow{P}\\theta$ (it converges in probability)\n\\item The estimate is asymptotically normal (cf. \\cite{wasserman2003all}, pp.122)\n\\end{enumerate}\n\n\n\\subsection{Maximum Likelihood Estimation}\n\nThe maximum likelihood estimator is the value $\\hat{\\theta}$ that maximizes the joint probability density of the data, called the likelihood function. \n\nFor i.i.d. random variables with pdf $f(x;\\theta)$, the likelihood function is:\n\n\\begin{equation}\n\\mathscr{L}_n(\\theta) = \\prod_{i=1}^n f(X_i;\\theta)\n\\end{equation}\n\nAnd the log likelihood functin is $l_n(\\theta) = \\log \\mathscr{L}_n(\\theta)$. Since $\\log$ is a monotonic function, maximizing the log-likelihood yields the same estimator as maximizing the likelihood directly. Log-likelihood is often easier to deal with, and alleviates numerical issues associated with the often sharply spiked likelihood function. \n\nMLE estimators have a flurry of desirable properties under certain smoothness conditions on the density function. \n\n\\begin{itemize}\n\\item Consistency: convergence in probability upon the true value\n\\item Equivariance: if $\\hat{\\theta}_n$ is the MLE of $\\theta$ then $g(\\hat{theta}_n)$ is the MLE of $g(\\theta)$\n\\item Asymptotically Normal\n\\item Asymptotically Optimal / Efficient: smallest variance, at least for large samples.\n\\item Approximately the Bayes estimator.\n\\end{itemize}\n\n\n\\subsection{Parametric Confidence Intervals}\n\nConfidence intervals for infered parameters in the parametric setting can be derived, for example, using the delta method (assuming that the estimators are asymptotically normal) or using parametric bootstrap. In the nonparametric case, bootstrap sampled from the empirical CDF. In the parametric case, bootstrap sample from the density $f(X;\\hat{\\theta})$ where $\\hat{\\theta}$ is the estimator.\n\n\n\\section{Score Function, Fisher Information}\nGiven some pdf $f(X;\\theta)$, the score function is given by: \n\n\\begin{equation}\ns(X;\\theta) \\frac{\\partial \\log f(X;\\theta)}{\\partial \\theta}\n\\end{equation}\n\nThe Fisher information is the variance of the score function at each datapoint:\n\n\\begin{equation}\nI_n(\\theta) = \\mathbb{V}_{\\theta} \\left(\\sum_{i=1}^n s(X_i ; \\theta) \\right)\n\\end{equation}\n\n\n", "meta": {"hexsha": "c14e62ae8513fbdc05f78263230fcc88bf0e6ecb", "size": 3422, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/sections/stats_parametricinference.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/sections/stats_parametricinference.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/sections/stats_parametricinference.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.7317073171, "max_line_length": 395, "alphanum_fraction": 0.7574517826, "num_tokens": 931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539660962919971, "lm_q2_score": 0.8872045981907006, "lm_q1q2_score": 0.8463631071482925}} {"text": "\\section{Vector Spaces and Subspaces}\r\nLet $F$ be an arbitrary field.\r\n\\begin{definition}\r\n An $F$-vector space (or a vector space over $F$) is an abelian group $(V,+)$ equipped with a function $F\\times V\\to V,(\\lambda,v)\\mapsto \\lambda v$ such that for any $v,v_1,v_2\\in V,\\lambda,\\mu\\in F$:\\\\\r\n 1. $\\lambda(v_1+v_2)=\\lambda v_1+\\lambda v_2$.\\\\\r\n 2. $(\\lambda_1+\\lambda_2)v=\\lambda_1v+\\lambda_2v$.\\\\\r\n 3. $\\lambda(\\mu v)=(\\lambda\\mu v)$.\\\\\r\n 4. $1v=v$.\\\\\r\n This function is often called scalar multiplication of the vector space.\r\n\\end{definition}\r\n\\begin{example}\r\n 1. Take $n\\in\\mathbb N$.\r\n Then the set of $n$-tuples in $F$, denoted $F^n$, is a vector space under the operations\r\n \\begin{align*}\r\n (x_1,\\ldots,x_n)+(y_1,\\ldots,y_n)&=(x_1+y_1,\\ldots,x_n+y_n)\\\\\r\n \\lambda(x_1,\\ldots,x_n)&=(\\lambda x_1,\\ldots,\\lambda x_n)\r\n \\end{align*}\r\n 2. For any set $X$, write $\\mathbb R^X=\\{f:X\\to\\mathbb R\\}$.\r\n It is a vector space over $\\mathbb R$ via\r\n $$(f_1+f_2)(x)=f_1(x)+f_2(x),(\\lambda f)(x)=\\lambda f(x)$$\r\n 3. The set $M_{n,m}(F)$ consisting of $F$-valued $n\\times m$ matrices is a vector space by interpreting it as $F^{n\\times m}$.\r\n\\end{example}\r\n\\begin{remark}\r\n The axioms of scalar multiplication imply that $0v=0$ for any $v\\in V$, as one can check.\r\n\\end{remark}\r\n\\begin{definition}[Subspace]\r\n Let $V$ be a vector space over $F$.\r\n A subset $U\\subset V$ is a subspace of $V$ (or $U\\le V$ as vector spaces) iff $U\\le V$ as subgroups and $\\forall\\lambda\\in F,u\\in U,\\lambda u\\in U$.\r\n\\end{definition}\r\nSo basically, a subgroup $U$ is a subspace if we can properly restrict the original scalar product to make it a vector space over $F$ as well.\r\nOne can also check oneself that a subspace of a subspace is also a subspace of the original space.\r\n\\begin{example}\r\n Take $V=\\mathbb R^{\\mathbb R}$.\r\n $C(\\mathbb R)\\le V$ (the set of continuous functions $\\mathbb R\\to\\mathbb R$) is a subspace of $V$, and the set of polynomials is a subspace of $C(\\mathbb R)$.\\\\\r\n Take $V=\\mathbb R^3$, then a line is a subspace iff it passes through the origin.\r\n A plane is a subspace iff it passes through the origin as well.\r\n\\end{example}\r\n\\begin{proposition}\r\n Let $V$ be an $F$-vector space and $U,W\\le V$ as vector spaces, then $U\\cap W\\le V$ as vector spaces.\r\n\\end{proposition}\r\n\\begin{proof}\r\n Just check.\r\n\\end{proof}\r\nHowever, the union of two subspaces is generally not a subspace unless one is contained in the other already.\r\n\\begin{example}\r\n Take $V=\\mathbb R^2$ and $U,W$ two axes, then $(1,0)+(0,1)=(1,1)$ is already not in the union.\r\n\\end{example}\r\n\\begin{definition}\r\n Let $V$ be an $F$-vector space.\r\n Let $U,W\\le V$.\r\n The sum of $U$ and $W$ is the set $U+W=\\{u+w:u\\in U, w\\in W\\}$.\r\n\\end{definition}\r\n\\begin{example}\r\n Take $V=\\mathbb R^2$ and $U,W$ two axes again, then $U+W=V$.\r\n\\end{example}\r\n\\begin{proposition}\r\n The sum of two subspaces is a subspace.\r\n\\end{proposition}\r\n\\begin{proof}\r\n Obvious.\r\n\\end{proof}\r\nJust to mention, one can easily check that $U+W$ is the smallest subspace of $V$ containing $U$ and $W$.\r\n\\begin{definition}\r\n Let $V$ be an $F$-vector space and $U\\le V$.\r\n The quotient space $V/U$ is the quotient group equipped with the scalar multiplication $\\lambda(v+U)=\\lambda v+U$.\r\n\\end{definition}\r\n\\begin{proposition}\r\n This scalar multiplication is well-defined and makes $V/U$ a vector space.\r\n\\end{proposition}\r\n\\begin{proof}\r\n Just check.\r\n\\end{proof}\r\n", "meta": {"hexsha": "f8d8e9f1ce832c577fd81d4409e77ab4aaf1b4bf", "size": 3517, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "1/spaces.tex", "max_stars_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_stars_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "1/spaces.tex", "max_issues_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_issues_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "1/spaces.tex", "max_forks_repo_name": "david-bai-notes/IB-Linear-Algebra", "max_forks_repo_head_hexsha": "5a499f7ed33ef0110facb27323e13f42883aa0c5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1780821918, "max_line_length": 207, "alphanum_fraction": 0.6545351152, "num_tokens": 1177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625069680098, "lm_q2_score": 0.9086179025005187, "lm_q1q2_score": 0.8463435093391478}} {"text": "%% Magic command to compile root document\n% !TEX root = ../../thesis.tex\n\n%% Reset glossary to show long gls names\n\\glsresetall\n\n%% Set path to look for the images\n\\graphicspath{{./Sections/Basics/Resources/}}\n\n% what is a ANN\n\nRoughly speaking, an \\gls{ann} is a non-linear function $f:\\mathbb{R}^D \\rightarrow \\mathbb{R}^L$, that maps an input $\\bs{x}\\in\\mathbb{R}^D$ with an output $\\bs{y}\\in\\mathbb{R}^L$. Of course, to consider $f$ as a \\gls{ann}, $f$ must have a specific form that will be address later. However, for the sake of this explanation, let us start by defining a simple function as follow\n\n\\begin{equation}\n \\begin{split}\n f(\\bs{x},\\bs{w}) &:= h \\left(w_0 + \\sum_{j=1}^{M-1}w_j\\phi_j(\\bs{x}) \\right) \\\\\n &= h(\\bs{w}^T\\bs{\\phi}(\\bs{x})) \\\\\n &:= h(z)\n \\end{split}\n \\label{eq:basics:slp}\n\\end{equation}\n\n\\noindent where $\\bs{\\phi}:\\mathbb{R}^{D+1} \\rightarrow \\mathbb{R}^M$ is an element-wise function, with $\\phi_0:=1$, know as \\hl{basis function}, $h:\\mathbb{R} \\rightarrow \\mathbb{R}$ is a function know as \\hl{activation function} and $\\bs{w}\\in\\mathbb{R}^M$ is the parameter vector. The parameters $w_j$, with $j\\in\\{1,\\dots M-1\\}$ are known as \\hl{weights}, while the parameter $w_0$ is know as \\hl{bias}.\n\nThen, an \\gls{ann} is composition of functions of the same form as \\ref{eq:basics:slp}, with non-linear \\hl{activation functions}, and where the basis functions are also of the same form as \\ref{eq:basics:slp} \\cite{bishop2006pattern}\n\n\\begin{equation}\n F(\\bs{x}, \\bs{W}) :=\n h_K(\\bs{w}^T_K h_{K-1}(\\bs{w}^T_{K-1} \\dots h_{0}(\\bs{w}^T_0 \\bs{x}) \\dots ))\n \\label{eq:basics:ann}\n\\end{equation}\n\nThe subscript in the parameter vectors $\\bs{w}_k$ and the activation functions $h_k$, with $k\\in\\{0, \\dots, K\\}$, of \\ref{eq:basics:ann} represents the depth of the layers. Note that unlike the other layers, the base function of the \\hl{input layer} (k = 0) is the identity function. Furthermore, the activation function of the \\hl{output layer} $h_K$ does not necessarily have to be non-linear. Instead, it is chosen based on the type of function we want to approximate. In our case, since we have a regression problem (predicting \\gls{tr}), $h_K$ is chosen as the identity function.\n\nThere are different non-linear activation functions that can be chosen for the hidden units. However, all the models showed in this work use the \\gls{relu}\n\n\\begin{equation}\n ReLU := max\\{0, x\\}\n\\end{equation}\n\nFigure \\ref{fig:basics:ann:relu} shows the \\gls{relu} activation function.\n\n% Figure made in notebook Preprocessing_resources.ipynb\n\\begin{figure}[!ht]\n \\centering\n \\includegraphics[width=0.6\\linewidth]{ReLU.jpg}\n \\caption{\\gls{relu} activation function.}\n \\label{fig:basics:ann:relu}\n\\end{figure}\n\nFigure \\ref{fig:basics:ann:ann} shows a graphical representation of a \\gls{ann}. The circles represent the activation function applied to what is inside it. Black colored circles represent the identity function, red colored circles the non-linear activation function for the hidden layers, while green any function for the output layer that suits the problem we want to solve. Note that values inside the circles of the hidden and output layers $z^k_i$, for $k\\in\\{0, \\dots, K\\}$ and $i$ representing one of the units of the $k$ layer, are the output of a function of the same form as \\ref{eq:basics:slp}. The lines connecting the circles represent the weights and biases corresponding to each layer $\\bs{W}_k$, for $k\\in\\{0, \\dots, K\\}$. The circles in the \\hl{hidden layers} are known as \\hl{hidden units}.\n\n\\begin{figure}[!ht]\n \\centering\n \\includegraphics[width=0.8\\linewidth]{Diagrams/ANN.jpg}\n \\caption{Graphical representation of an \\gls{ann}. The color of the circles represents the type of activation function. Black means the identity, red a non-linear function for the hidden layers and green any function for the output layer.}\n \\label{fig:basics:ann:ann}\n\\end{figure}\n\nStrictly speaking, equation \\ref{eq:basics:ann} and figure \\ref{fig:basics:ann:ann} represent a \\hl{fully connected feedforward neural network}. However, in this work we will refer to it just as \\gls{ann}, which in some literature is also known as \\gls{mlp}. Also, hidden layers are also known as \\hl{Dense layers}.\n\n\\subsubsection{Update rule}\n\nSow far we have introduced the general form an \\gls{ann} must have. Moreover, equation \\ref{eq:basics:ann} shows that an \\gls{ann} is simply a non-linear function controlled by a set of adjustable parameters $\\bs{W}$. Therefor the question is, how can we approximate this parameters?\n\nRecall that we are dealing with a supervised learning problem, which means that we can use both the input data (images of cell nucleus, $\\bs{X}$) and the output data (the \\glspl{tr}, $\\bs{Y}$) to approximate $\\bs{W}$. Therefore, we can fed the \\gls{ann} with $\\bs{X}$, and then measure its performance by comparing its output $\\hat{\\bs{Y}}$ against the true values $\\bs{Y}$.\n\nThis comparison is made by means of a \\hl{loss function} $\\mathcal{L}$ that must be chosen beforehand. The choice of $\\mathcal{L}$ depends mainly on the type of problem you are solving (regression, classification, etc.). However, even for each type, there are many different options. For now, let us just say that $\\mathcal{L}$ should return high values when $\\hat{\\bs{Y}}$ is far from the true values $\\bs{Y}$, and low when they are close.\n\nThen, we can fit the values of $\\bs{W}$, by minimizing the loss function $\\mathcal{L}$ each time the model is fed with an input value $\\bs{x}$. Since the gradient of $\\mathcal{L}$ with respect to $\\bs{W}$ (i.e., $ \\nabla_{\\bs{W}} \\mathcal{L}$) returns the direction in which the loss function grows the fastest, then we choose $- \\nabla_{\\bs{W}} \\mathcal{L}$ as the direction of our update rule\n\n\\begin{equation}\n \\bs{W}_{new} = \\bs{W}_{old} - \\alpha \\nabla_{\\bs{W}} \\mathcal{L}(\\bs{W}_{old})\n \\label{eq:basics:ann:learn_rule}\n\\end{equation}\n\n\\noindent where $\\alpha \\in \\mathbb{R}^+$ (known as \\hl{learning rate}) controls how much we move in the direction of $-\\nabla_{\\bs{W}} \\mathcal{L}(\\bs{W}_{old})$ on every step.\n\nThe iterative method in which \\ref{eq:basics:ann:learn_rule} is applied over elements of $\\bs{X}$ to optimize $\\bs{W}$ is known as \\gls{gd} \\cite{bishop2006pattern}.\nHowever, in practice \\ref{eq:basics:ann:learn_rule} is not applied for a single element of $\\bs{X}$ every time, but to a random subset of $\\bs{X}$ (known as a \\hl{Batch}) instead.\nThe number of elements in batch is fixed over all the iteration (training), and is an hyperparameter known as \\hl{Batch Size} $bs$\\footnote{Normally the training data is separated in disjoint batches, which means that it could happen that last batch to be smaller than the selected $bs$.}.\nAs a rule of thumb, $bs$ should be no less than 30 (for the selected sample to be representative of $\\bs{X}$). In practice $bs$ is usually chosen as a power of 2.\nThis process is known as \\gls{sgd} and computationally is less expensive than \\gls{gd}.\n\nHowever, \\gls{gd} (\\gls{sgd}) has a downside, the choice of its hyperparameter $\\alpha$ (learning rate). In practice, it has been shown that the correct choice of $\\alpha$ is essential to train an \\gls{ann} successfully. Therefore, other algorithms (\\hl{optimizers}) have been proposed to mitigate this problem. The revision of these optimizers is out of the scope to this work. However, all of them follow the same idea proposed by \\gls{gd}. For example, instead of having a fixed learning rate $\\alpha$ as in \\gls{gd}, the \\gls{adam} optimizer adapts its learning rate dynamically during training depending on the mean and variance of the loss function \\cite{kingma2014adam}.\n\n\\subsubsection{Back propagation}\n\nNevertheless, there is still one question that needs to be answered, which is how to efficiently calculate the derivative of the loss function ($\\nabla_{\\bs{W}} \\mathcal{L}$) with respect to all the parameters of the \\gls{ann}. The answer to this is through an algorithm called \\hl{backpropagation}, which is performed during the \\hl{training process}. Again, there is a lot of literature that explains this in depth(for instance \\cite{Goodfellow-et-al-2016} or \\cite{bishop2006pattern}). Therefor, here we will just provide the intuition behind it.\n\nRecall that $\\mathcal{L}$ is a function of the true values $y$ and $\\hat{y}$ i.e., $\\mathcal{L}(y, \\hat{y})$. Also from equation \\ref{eq:basics:ann} and figure \\ref{fig:basics:ann:ann} note that\n\n\\begin{equation}\n \\begin{split}\n y &:= F(\\bs{x}, \\bs{W}) \\\\\n &= h_K(\\bs{z}^K) \\\\\n &= h_K(\\bs{W}_K^T h_{K-1}(\\bs{z}^{K-1}))\n \\end{split}\n \\label{eq:basics:ann:backprop_1}\n\\end{equation}\n\nand therefore\n\n\\begin{equation}\n \\begin{split}\n \\nabla_{\\bs{W}_K} \\mathcal{L} &= \\frac{\\partial \\mathcal{L}}{\\partial \\bs{W}_K} \\\\\n &= \\frac{\\partial \\mathcal{L}}{\\partial \\hat{y}}\n \\frac{\\partial \\hat{y}}{\\partial \\bs{z^K}}\n \\frac{\\partial \\bs{z^K}}{\\partial \\bs{W}_K} \\\\\n \\end{split}\n \\label{eq:basics:ann:backprop_2}\n\\end{equation}\n\n\\noindent which is just the product of the derivative of the loss function w.r.t. $\\hat{y}$ (i.e., $\\frac{\\partial \\mathcal{L}}{\\partial \\hat{y}}$), the derivative of the activation function of the output layer w.r.t the argument of the last layer (i.e., $\\frac{\\partial \\hat{y}}{\\partial \\bs{z^K}}$) and the output of the layer $K-1$ (i.e., $\\frac{\\partial \\bs{z^K}}{\\partial \\bs{W}_K}=h_{K-1}(\\bs{z^{K-1}})$).\n\nNote that we can easily compute the gradient of $\\mathcal{L}$ w.r.t deeper parameters $\\bs{W}_k$ (for $k\\in\\{0, \\dots, K-1\\}$), just by extending \\ref{eq:basics:ann:backprop_1} and \\ref{eq:basics:ann:backprop_2}.\n\nThis shows how by means of the \\hl{chain rule}\\footnote{$(f \\circ g)'=(f \\circ g) \\cdot g'$, or equivalently $h'(x)=f'(g(x))g'(x)$, for $h(x):=f(g(x))$.}, the backpropagation algorithm can compute the gradient of the loss function w.r.t. a specific parameter, just by multiplying the derivative of the loss function, the derivative of the activation functions and some values computed during the evaluation of the \\gls{ann}.\n\n\\subsubsection{Model development}\n\nThe properties of \\glspl{ann} have been studied extensively before (\\cite{cybenko1989approximation}, \\cite{hornik1989multilayer}, \\cite{funahashi1989approximate}) and established in the \\hl{Universal approximation theorem}\n\n\\begin{theorem}[Universal approximation theorem]\n An \\gls{mlp} with a linear output layer and one hidden layer can approximate any continuous function defined over a closed and bounded subset of $\\mathbb{R}^D$, under mild assumptions on the activation function (\\hl{squashing} activation function) and given the number of hidden units is large enough.\n\\end{theorem}\n\nFor this reason \\gls{ann} are known as \\hl{universal approximators}, since they are able to approximate any continuous function on a compact\\footnote{A set $A$ in a metric space is said to be \\hl{compact} if it is close (i.e., it contain all its limit points) and bounded (i.e., all its points lie within some fixed distance of each other) \\cite{bartle2000introduction}.} input domain with an arbitrary accuracy \\cite{bishop2006pattern}.\n\nThese means that, as long as a \\gls{ann} has a sufficiently large number of hidden units, the loss function can be reduced as much as desired. However, this nice property can also lead to an unwanted one known as \\hl{overfitting}.\nIntuitively this means that the \\gls{ann} \\hl{memorize} the data used to train it (low error/bias), and therefore it is not able to perform (or \\hl{generalize}) well when it is fed with new data (high error/bias and variance). This happens mainly when the \\gls{ann} is optimized/fed too many times with the same data.\n\nOn the other hand, \\hl{underfitting} means that the \\gls{ann} performs poorly on both new data and data used to train the network (high bias and low variance). This usually happens when the training time is insufficient or the \\gls{ann} is not complex enough (too few hidden units and/or layers).\n\nFigure \\ref{fig:basics:ann:fitting} shows synthetic data (blue circles), generated from a sine function (green line) and random noise sampled from a normal distribution.\nThe red line in figure \\ref{fig:basics:ann:fitting:under} represents a fitted model with high bias and low variance (underfitting), while in figure \\ref{fig:basics:ann:fitting:over} a model with low bias and high variance (overfitting). The red line in figure \\ref{fig:basics:ann:fitting:good}, represents a model with low bias and variance (good fit and good generalization).\n\n% this plots were extracted from page 7 (Bishop) and adapted in the file overfitting.odg\n\\begin{figure}[htb]\n \\centering\n \\begin{subfigure}[t]{.3\\linewidth}\n \\includegraphics[width=\\linewidth]{Diagrams/underfitting.jpg}\n \\caption{Underfitted model.}\n \\label{fig:basics:ann:fitting:under}\n \\end{subfigure}\n \\vspace{3mm}\n \\begin{subfigure}[t]{.3\\linewidth}\n \\includegraphics[width=\\linewidth]{Diagrams/goodfit.jpg}\n \\caption{Model with good fit and generalization.}\n \\label{fig:basics:ann:fitting:good}\n \\end{subfigure}\n \\vspace{3mm}\n \\begin{subfigure}[t]{.3\\linewidth}\n \\includegraphics[width=\\linewidth]{Diagrams/overfitting.jpg}\n \\caption{Overfitted model.}\n \\label{fig:basics:ann:fitting:over}\n \\end{subfigure}\n \\caption{Representation of a model (red line) with underfitting \\subref{fig:basics:ann:fitting:under}), good fit \\subref{fig:basics:ann:fitting:good}) and overffiting \\subref{fig:basics:ann:fitting:over}), trained over synthetic data (blue small circles). The synthetic data was generating by adding random noise to a sine function (green line) on the interval $[0,1]$. Image source \\cite{bishop2006pattern}.}\n \\label{fig:basics:ann:fitting}\n\\end{figure}\n\nIn practice, we seek to fit models that has low bias and low variance (i.e., good accuracy and good generalization). Therefore, to prevent overfitting we split the data into 3 different sets; \\hl{training}, \\hl{validation} and \\hl{test}, and train the model using only the first set. Then, during model training, we measure how well the model is generalizing by comparing the value of the loss function when it is evaluated in the training and validation set \\footnote{This is usually known as the \\hl{bias–variance tradeoff}.}.\nDuring the model development, the \\hl{test} set is never evaluated and is only used at the end, to report the model performance. This methodology is shown in figure \\ref{fig:basics:model_train_process}\n\nFigure \\ref{fig:basics:bias_variance} shows this \\hl{bias–variance tradeoff} between training and validation set. In practice, multiple versions of the model are saved during training and then the one with the lowest validation error is chosen (red dot on figure \\ref{fig:basics:bias_variance}).\n\n% figure taken from BL_070121_0942.ipynb\n\\begin{figure}[!ht]\n \\centering\n \\includegraphics[width=0.8\\linewidth]{bias_variance.png}\n \\caption{Bias–variance tradeoff. In orange (respectively blue) the loss function curve when it is evaluated in the validation (respectively training) set. The red dot shows the lowest loss for the validation set.}\n \\label{fig:basics:bias_variance}\n\\end{figure}\n\n\\begin{figure}[!ht]\n \\centering\n \\includegraphics[width=0.8\\linewidth]{Diagrams/Model_methodologt.jpg}\n \\caption{Model development methodology.}\n \\label{fig:basics:model_train_process}\n\\end{figure}\n\nThe methodology shown in figure \\ref{fig:basics:model_train_process} is also used to optimize the hyperparameters of the model, like the number hidden units/layers or the activation function of the hidden layers.\n\n\\subsubsection{Batch Normalization}\n\nHowever, overfitting is not the only problem we may encounter when training an \\gls{ann}. Training \\gls{ann} with several layers can be complicates, since the distribution of the data can change from layer to layer. This means that the input and output distribution of a layer will not necessarily be the same. It has been empirically proven that this can affect the training performance, since it require the use of lower learning rates \\cite{ioffe2015batch}. This can also lead to \\hl{saturation}\\footnote{\\hl{Saturation} is a commonly used term to refer to the situation when the evaluation of a \"squashing\" function returns values close to some of its horizontal asymptotes most of the time. Remember that these \"squash\" functions (like \\hl{Sigmoid} or \\hl{tanh}) compress the real line $(-\\inf, \\inf)$ into an interval of finite length $(a, b)$.} of the activation functions, so a more careful initialization of the \\gls{ann} parameters is required. To address this problem Ioffe et al. \\cite{ioffe2015batch} proposed to normalize the layer inputs.\n\nRoughly speaking, batch normalization consist of two main steps; 1) the standardization of the layer input and 2) the normalization of the standardized data. For the first step the layer input is standardized using parameters extracted from the \\hl{batch}\n\n\\begin{equation}\n \\bs{z}'_k := \\frac{\\bs{z}_k-\\bs{\\mu}_k}{\\sqrt{\\bs{\\sigma}_k^2-\\epsilon}}\n\\end{equation}\n\\noindent with\n\\begin{equation}\n \\begin{split}\n \\bs{\\mu}_k &= \\frac{1}{M}\\sum_{m=1}^M \\bs{z}_k \\\\\n \\bs{\\sigma}_k^2 &= \\frac{1}{M}\\sum_{m=1}^M (\\bs{z}_k - \\bs{\\mu}_k)^2 \\\\\n \\end{split}\n\\end{equation}\n\n\\noindent where $M$ is the \\hl{Batch} size and $k$, with $k \\in \\{0 \\dots K\\}$, denotes the layer.\n\nNote that for each layer $k$ we have different normalization parameters $\\bs{\\mu}_k$ and $\\bs{\\sigma}_k$. Moreover, this normalization parameters are vectors of the same shape as the layer size (i.e., one pair of normalization parameters per unit/neuron).\n\nThe second step in batch normalization consist on normalizing the standardized data $\\bs{z}'_k$ using parameters $\\bs{\\gamma}_k$ and $\\bs{\\beta}_k$ learned during training\n\n\\begin{equation}\n \\overset{\\sim}{\\bs{z}}_k := \\bs{\\gamma}_k \\odot \\bs{z}'_k + \\bs{\\beta}_k\n\\end{equation}\n\n\\noindent where $\\odot$ denotes \\hl{element-wise} multiplication. At the beginning of the training $\\bs{\\gamma}_k=1$ and $\\bs{\\beta}_k=0$ are used for all the layers and units.\n\nDuring training, the normalization parameters of each epoch are stored, so the average ($\\bar{\\bs{\\gamma}}_k$ and $\\bar{\\bs{\\beta}}_k$) can be used during evaluation (when the model is not training).\n\n\\subsubsection{Residual Block V2}\n\nAs already mentioned, the \\hl{Universal approximation theorem} guarantees that the training error can be reduced by adding more layer to an \\gls{ann}. However, in practice it is not that simple. As we add layers to an \\gls{ann}, the training becomes more unstable and difficult as we can face vanishing or exploding gradients (when the value of the gradients become very close to 0 or $\\inf$ respectively during back propagation). To overcome this problem, He et al. (\\cite{he2015deep} and \\cite{he2016identity}) proposed the \\hl{residual blocks}, which have been empirically shown to make deep \\gls{ann} training more stable.\nThe core idea of residual blocks is to reformulate the layers as \\hl{learning residual functions} with reference to the layer inputs, by adding an \\hl{identity connection}. Then, if a layer is not longer beneficial to the \\gls{ann} (e.g. in case of gradient vanishing), the \\gls{ann} can just \"skip\" it. Figure \\ref{fig:basics:residual_block} shows a diagram of the second version of a residual block \\cite{he2016identity}.\n\n\\begin{figure}[!ht]\n \\centering\n \\includegraphics[width=\\linewidth]{Diagrams/Residual_block_v2.jpg}\n \\caption{Residual block V2.}\n \\label{fig:basics:residual_block}\n\\end{figure}\n", "meta": {"hexsha": "0bbbd8b7ee039b810a9552febc3305f978d4c1ed", "size": 19515, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Manuscript/Sections/Basics/Artificial_Neural_Networks.tex", "max_stars_repo_name": "andresbecker/master_thesis", "max_stars_repo_head_hexsha": "c67b8309b524ccfd02448573f2352ce57b5531cc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Manuscript/Sections/Basics/Artificial_Neural_Networks.tex", "max_issues_repo_name": "andresbecker/master_thesis", "max_issues_repo_head_hexsha": "c67b8309b524ccfd02448573f2352ce57b5531cc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Manuscript/Sections/Basics/Artificial_Neural_Networks.tex", "max_forks_repo_name": "andresbecker/master_thesis", "max_forks_repo_head_hexsha": "c67b8309b524ccfd02448573f2352ce57b5531cc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 86.3495575221, "max_line_length": 1053, "alphanum_fraction": 0.7419420958, "num_tokens": 5572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9572777987970316, "lm_q2_score": 0.8840392725805822, "lm_q1q2_score": 0.8462711689060688}} {"text": "\\section{K-Means Clustering}\nCLustering seeks to group similiar points of data together in a cluster. We\ndenote $c^{(i)}$ as the cluster for data point $i$ and $\\mu_j$ as the center\nfor cluster $j$. We denote $k$ as the number of clusters and $n$ as the\ndimension of our data.\n\\subsection{Algorithm}\nAfter randomly initializing the cluster centroids\n$\\mu_1, \\mu_2, \\hdots, \\mu_k \\in \\mathbb{R}^n$, repeat until convergence:\n\\begin{enumerate}\n \\item For every data point $i$:\n \\begin{equation}\n c^{(i)}=\\underset{j}{\\textrm{arg min}}||x^{(i)}-\\mu_j||^2\n \\end{equation}\n \\item For each cluster $j$:\n \\begin{equation}\n \\mu_j=\\frac{\\displaystyle\\sum_{i=1}^m1_{\\{c^{(i)}=j\\}}x^{(i)}}{\\displaystyle\\sum_{i=1}^m1_{\\{c^{(i)}=j\\}}}\n \\end{equation}\n\\end{enumerate}\nThe first step is known as cluster assignment, and the second updates the\ncluster center (i.e. the average of all points in the cluster). In order to\nsee if it converges, use the distortion function:\n\\begin{equation}\n J(c,\\mu)=\\sum_{i=1}^m||x^{(i)}-\\mu_{c^{(i)}}||^2\n\\end{equation}\nThe distortion function $J$ is non-convex, and coordinate descent of $J$ is not\nguaranteed to converge to the global minimum (i.e. susceptible to local optima).\n\\subsection{Hierarchical Clustering}\nHierarchical clustering is a clustering algorithm with an agglomerative\nhierarchical approach that builds nested clusters in a successive manner. The\ntypes are:\n\\begin{enumerate}\n \\item Ward Linkage: minimize within cluster distance\n \\item Average Linkage: minimize average distance between cluster pairs\n \\item Complete Linkage: minimize maximum distance between cluster pairs\n\\end{enumerate}\n\\subsection{Clustering Metrics}\nIn an unsupervised learning setting, it is often hard to assess the\nperformance of a model since we don't have the ground truth labels as was\nthe case in the supervised learning setting.\n\\paragraph{Silhouette coefficient} By noting $a$ and $b$ the\nmean distance between a sample and all other points in the same class,\nand between a sample and all other points in the next nearest cluster,\nthe silhouette coefficient $s$ for a single sample is defined as follows:\n\\begin{equation}\n s = \\frac{b - a}{\\max(a, b)}\n\\end{equation}\n\\paragraph{Calinskli-Harabaz Index} By noting $k$ the number of clusters, $B_k$\nand $W_k$ the between and within-clustering dispersion matricies defined as:\n\\begin{equation}\n B_k=\\sum_{j=1}^kn_{c^{(i)}}(\\mu_{c^{(i)}}-\\mu)(\\mu_{c^{(i)}}-\\mu)^T\n\\end{equation}\n\\begin{equation}\n W_k=\\sum_{i=1}^m(x^{(i)}-\\mu_{c^{(i)}})(x^{(i)}-\\mu_{c^{(i)}})^T\n\\end{equation}\nthe Calinksli-Harabaz index $s(k)$ indicated how well a clustering model\ndefines its clusters, such that higher scores indicate more dense and well\nseparated cluster assignments. It is defined as:\n\\begin{equation}\n s(k)=\\frac{\\textrm{Tr}(B_k)}{\\textrm{Tr}(W_k)}\\times\\frac{N-k}{k-1}\n\\end{equation}\n", "meta": {"hexsha": "d95b567c792964b1c605391d634d4a6d3e803077", "size": 2873, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "study_guide/sections/kmeans.tex", "max_stars_repo_name": "nextBillyonair/StudyGuide", "max_stars_repo_head_hexsha": "3fbb85c1f738878935c18280d728ca7e92aa1414", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-02-18T19:47:01.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-17T21:49:14.000Z", "max_issues_repo_path": "study_guide/sections/kmeans.tex", "max_issues_repo_name": "nextBillyonair/StudyGuide", "max_issues_repo_head_hexsha": "3fbb85c1f738878935c18280d728ca7e92aa1414", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "study_guide/sections/kmeans.tex", "max_forks_repo_name": "nextBillyonair/StudyGuide", "max_forks_repo_head_hexsha": "3fbb85c1f738878935c18280d728ca7e92aa1414", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.0983606557, "max_line_length": 112, "alphanum_fraction": 0.7267664462, "num_tokens": 879, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465098415278, "lm_q2_score": 0.9046505376715775, "lm_q1q2_score": 0.8461617230373716}} {"text": "\nThe Weibull distribution may be useful for fitting fat-tailed\nempirical distributions.\n\nIn the literature, the Weibull is sometimes called a ``stretched\nexponential'' distribution when its shape parameter $\\tau$ is less\nthan 1. ``Stretched exponential'' distributions in the literature are\neither Weibull (PDF $ = \\lambda \\tau (\\lambda x)^\\tau exp\\left[-\n(\\lambda x)^tau \\right]$ or a more simple PDF $\\propto exp\\left[-\n{\\lambda(x-\\mu)}^tau \\right]$. Easel treats the latter form in the\n\\eslmod{stretchexp} module.\n\n\\subsection{Weibull densities}\n\nThe probability density function (PDF) is:\n\n\\begin{equation}\nP(X=x) = \\lambda \\tau [\\lambda(x - \\mu)]^{\\tau-1} e^{- [\\lambda(x-\\mu)]^{\\tau}}\n\\label{eqn:weibull_pdf}\n\\end{equation}\n\nThe cumulative distribution function (CDF) is:\n\n\\begin{equation}\nP(X \\leq x) = 1 - e^{- [\\lambda(x-\\mu)]^{\\tau}}\n\\label{eqn:weibull_cdf}\n\\end{equation}\n\nVariate $x$ ranges $\\mu \\leq x < \\infty$. (However, for $\\tau < 1$,\nthe PDF goes to infinity at $x=\\mu$, so evaluating at $x=\\mu$ may not\nbe desired.)\n\nLocation parameter $\\mu$ is unconstrained, $-\\infty < \\mu <\n\\infty$. (Weibull distributions are usually represented without an\nexplicit location parameter, implicitly assuming $\\mu = 0$.)\n\nScale parameter $\\lambda$ is nonnegative, $\\lambda >\n0$. (Alteratively, Weibull distributions are also sometimes\nrepresented with a scale parameter $b = \\frac{1}{\\lambda}$.)\n\nShape parameter $\\tau$ is nonnegative, $\\tau > 0$. \n\n\n\n\n\n\n", "meta": {"hexsha": "4b435a702ffa2bb5342ca81a1838627aab584581", "size": 1458, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "hmmer-3.3/easel/esl_weibull.tex", "max_stars_repo_name": "WooMichael/Project_Mendel", "max_stars_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hmmer-3.3/easel/esl_weibull.tex", "max_issues_repo_name": "WooMichael/Project_Mendel", "max_issues_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hmmer-3.3/easel/esl_weibull.tex", "max_forks_repo_name": "WooMichael/Project_Mendel", "max_forks_repo_head_hexsha": "ff572f7ce7f9beca148f7351cf34dbf11d670bc8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.375, "max_line_length": 79, "alphanum_fraction": 0.7085048011, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067195846918, "lm_q2_score": 0.8976952873175982, "lm_q1q2_score": 0.8460838404363469}} {"text": "\\section{Derivatives of VVFs}\r\n\\noindent\r\nJust like functions from Calc I and II, we can differentiate VVFs.\r\nIn fact, the limit definitions of the derivative are nearly identical.\r\nLet $\\vec{r}(t) = \\langle x(t), y(t), z(t) \\rangle$.\r\n\\begin{align*}\r\n\t\\vec{r^\\prime}(t) &= \\lim_{h\\to 0}{\\frac{\\vec{r}(t+h)-\\vec{r}(t)}{h}} \\\\\r\n\t&= \\lim_{h\\to 0}{\\bigg\\langle \\frac{x(t+h)-x(t)}{h}, \\frac{y(t+h)-y(t)}{h}, \\frac{z(t+h)-z(t)}{h} \\bigg\\rangle}.\r\n\\end{align*}\r\nThe limit distributes inside the vector, so\r\n\\begin{equation*}\r\n\t\\vec{r^\\prime}(t) = \\langle x^{\\prime}(t), y^{\\prime}(t), z^{\\prime}(t) \\rangle.\r\n\\end{equation*}\r\n\r\n\\noindent\r\nLike a position function from Calc I and II, the derivative of a VVF representing position gives a VVF representing velocity, and the 2nd derivative gives a VVF representing acceleration.\r\nThe magnitude of the velocity VVF, the speed, is commonly notated $v(t)$.\\\\\r\n\r\n\\noindent\r\nThere are 5 important properties of the derivatives of VVFs.\r\nThese properties are similar to single-variable derivatives.\r\nLet $\\vec{r}(t)$ and $\\vec{s}(t)$ be VVFs, $a(t)$ be a scalar function, and $c$ be a scalar.\r\n\\begin{enumerate}[label=]\r\n\t\\item \\textbf{Linearity}\r\n\t\\begin{equation*}\r\n\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}c\\vec{r}(t) = c\\vec{r^\\prime}(t)\r\n\t\\end{equation*}\r\n\t\\item \\textbf{Product Rule for Scalar Functions}\r\n\t\\begin{equation*}\r\n\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}a(t)\\vec{r}(t) = a(t)\\vec{r^\\prime}(t) + \\vec{r}(t)a^{\\prime}(t)\r\n\t\\end{equation*}\r\n\t\\item \\textbf{Dot Product Rul}e\r\n\t\\begin{equation*}\r\n\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\vec{s}(t)\\cdot\\vec{r}(t) = \\vec{s}(t)\\cdot\\vec{r^\\prime}(t) + \\vec{r}(t)\\vec{s^\\prime}(t)\r\n\t\\end{equation*}\r\n\t\\item \\textbf{Cross Product Rule}\r\n\t\\begin{equation*}\r\n\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\vec{s}(t)\\times\\vec{r}(t) = \\vec{s}(t)\\times\\vec{r^\\prime}(t) + \\vec{s^\\prime}(t)\\times\\vec{r}(t)\r\n\t\\end{equation*}\r\n\t\\item \\textbf{Chain Rule}\r\n\t\\begin{equation*}\r\n\t\t\\frac{\\mathrm{d}}{\\mathrm{d}t}\\vec{r}(a(t)) = \\vec{r^\\prime}(a(t))a^{\\prime}(t)\r\n\t\\end{equation*}\r\n\\end{enumerate}\r\nA quotient rule doesn't make sense because we don't have an operation for dividing two vectors by each other.\\\\\r\n\r\n\\noindent\r\nJust like in single variable calculus, we can use the derivative of VVFs to find tangent lines to the curve.\r\nSimilar to how $f^{\\prime}(a)$ represents the slope of $f$ at $a$, $\\vec{r^\\prime}(a)$ represents the direction of the tangent line at $a$.\r\nRemembering the VVF form of a line, the tangent line to $\\vec{r}$ at $t$ is \r\n\\begin{equation*}\r\n\t\\vec{l}(t)=\\vec{r}(t)+t\\vec{r^\\prime}(t).\r\n\\end{equation*}\r\nIn fact, tangent lines appear so often, that we have a special unit vector representing the direction of the tangent line.\r\n\\begin{equation*}\r\n\t\\hat{T}(t) = \\frac{\\vec{r^\\prime}(t)}{\\norm{\\vec{r^\\prime}(t)}}.\r\n\\end{equation*}\r\nYou can remember $\\hat{T}$ as the ``tangent'' vector.\r\n\r\n\\begin{figure}[H]\r\n\t\\centering\r\n\t\\includegraphics[scale=0.33]{Images/vectorValuedFunctions/TangentVector}\r\n\t\\caption{$\\hat{T}$ is $\\vec{r^\\prime}$ normalized.}\r\n\\end{figure}", "meta": {"hexsha": "6d27ff2a78565480246d19cf49eeb761af90057d", "size": 3035, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "multiCalc/vectorValuedFunctions/DerivativesOfVVFs.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "multiCalc/vectorValuedFunctions/DerivativesOfVVFs.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "multiCalc/vectorValuedFunctions/DerivativesOfVVFs.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 47.421875, "max_line_length": 188, "alphanum_fraction": 0.6602965404, "num_tokens": 1072, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191335436404, "lm_q2_score": 0.8856314828740729, "lm_q1q2_score": 0.8460607008582287}} {"text": "\\lecture{Sept. 27}\n\n\\begin{defn}\n\\textbf{Interpretation} is a choice of a non-empty set u, and constant, functions and relations for each constant, function and relation symbol.\n\nAn \\textbf{Assignment} in u, $$\\alpha \\colon \\{\\text{variale symbols}\\}\\to u$$\n\nWe write $\\alpha (F) = 1$ when F is true in u under $\\alpha$.\n\nWe write $\\alpha (F) = 0$ when F is false in u under $\\alpha$.\n\nWe say F is true in u when $\\alpha (F) = 1$ for \\textbf{every} assignment $\\alpha \\in u$\n\\end{defn}\n\n\\begin{exmp}\nthe formula $x\\times y = y \\times x$ is true in $\\mathbb{Z}$ but not true in $n\\times n$ matrices.\n\\end{exmp}\n\n\\begin{defn}\nFor formulas F and G and a set of formulas S, we say that F is a \\textbf{tautology} and we write $\\vDash F$, when for every interpretation u and every assignment $\\alpha \\in u$, $\\alpha (F) = 1$\n\\end{defn}\n\n\\begin{defn}\nWe say that F and G are \\textbf{equivalent}, and we write $F\\equiv G$, when for every interpretation u, for every assignment $\\alpha \\in u$, $\\alpha (F) = \\alpha (G)$, we say that the argument ``F there fore G\" is valid, or that ``S induces G\", or that ``G is a consequences of S\", when for every interpretation u and for every assignment $\\alpha \\in u$, if $\\alpha (F) = 1$ for every $F\\in S$ then $\\alpha (G) = 1$\n\\end{defn}\n\n\\begin{defn}\nGiven a formula G and a set of formulas S, such that $S\\vDash G$, a \\textbf{derivation} for the valid argument $S\\vDash G$ is a list of valid arguments\n$$S_1\\vDash G_1,S_2\\vDash G_2,S_3\\vDash G_3,\\dots$$\nwhere for some index k we have $S_k=S$ and $G_k = G$, such that each valid argument in the list is obtained from previous valid arguments in the list by applying one of the basic validity rules.\n\\end{defn}\n\n\\section{Basic Validity Rules}\nEach basic validity rule is a formal and precise way of describing standard method of mathematical proof.\n\nRules V1, V2 and V3 are used in derivations because we make a careful distinction between \\textbf{premises} and \\textbf{conclusions}. In standard mathematical proofs we do not make a careful distinction.\n\n\\begin{enumerate}\n\\item[Premise V1.] If $F\\in S$ then $S\\vDash F$. In words, if we assume $F$, we can conclude $F$.\n\\item[V2.] If $S\\vDash F$ and $S\\subseteq \\mathcal{T}$ then $\\mathcal{T}\\vDash F$. In words, if we can prove $F$ without assuming $G$, then we can still prove $F$ if we assume $G$.\n\\item[Chain Rule V3.] If $S\\vDash F$ and $S\\cup \\{F\\}\\vDash G$ then $S\\vDash G$. In words, if we can prove $F$, and by assuming $F$ we can prove $G$, then we can prove $G$ directly without assuming $F$.\n\\item[Proof by Cases V4.] If $S\\cup \\{F\\}\\vDash G$ and $S\\cup \\{\\neg F\\}\\vDash G$ then $S\\vDash G$. In words, in either case $G$ is true.\n\\item[Contradiction V5.] If $S\\cup \\{\\neg F\\} \\vDash G$ and $S\\cup \\{\\neg F\\} \\vDash \\neg G$ then $S\\vDash F$. In words, to prove F by contradiction, we suppose, for a contradiction, that F is false, we choose a formula G, then we prove that G is true and we prove that G is false.\n\\item[V6.] If $S\\cup \\{ F\\} \\vDash G$ and $S\\cup \\{ F\\} \\vDash \\neg G$ then $S\\vDash \\neg F$\n\\item[V7.] If $S\\vDash F$ and $S\\vDash \\neg F$ then $S\\vDash G$\n\\item[Conjunction V8.] $S\\vDash F\\wedge G \\Longleftrightarrow (S\\vDash F \\text{ and } S\\vDash G)$\n\\item[V9.] If $S\\cup \\{F,G\\} \\vDash H$ then $S\\cup \\{F\\wedge G\\}\\vDash H$\n\\item[V10.] ...\n\\item[V11.] ...\n\\item[V12.] ...\n\\item[Disjunction V13.] $S\\vDash F\\vee G \\Longleftrightarrow S\\cup \\{\\neg F\\}\\vDash \\Longleftrightarrow S\\cup \\{\\neg G\\}\\vDash F$\n\\item[V14.] ...\n\\end{enumerate}\n\n\n", "meta": {"hexsha": "6d681be221df9409e11727fc7ef886730708a101", "size": 3500, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "MATH 145/lecture/11.tex", "max_stars_repo_name": "Zhongweizhao/uw-notes", "max_stars_repo_head_hexsha": "bfb0f7b5f3607e9827f86092af5c5b9e2b875239", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-14T16:46:12.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-14T16:46:12.000Z", "max_issues_repo_path": "MATH 145/lecture/11.tex", "max_issues_repo_name": "Zhongweizhao/uw-notes", "max_issues_repo_head_hexsha": "bfb0f7b5f3607e9827f86092af5c5b9e2b875239", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "MATH 145/lecture/11.tex", "max_forks_repo_name": "Zhongweizhao/uw-notes", "max_forks_repo_head_hexsha": "bfb0f7b5f3607e9827f86092af5c5b9e2b875239", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.5, "max_line_length": 415, "alphanum_fraction": 0.6854285714, "num_tokens": 1163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533107374443, "lm_q2_score": 0.9073122244934722, "lm_q1q2_score": 0.8460262876014935}} {"text": "\t\\chapter{Vector Spaces}\n\t\n\tA vector space is the general mathemtical structure we need to be able to talk about linear mappings. To introduce a vector space we need a lot of mathematical concepts. So we start with a group. \n\t\n\t\\begin{definition}\n\t\tA set $G$ of elements with an operation $+$: $G \\times G \\rightarrow G$ is called a group if the following properties hold: \n\t\\end{definition}\n\t\n\t\\begin{itemize}\n\t\t\\item[G1] Associativity: $ \\forall a, b, c \\in G$ : $(a + b) + c = a + (b + c) $\n\t\t\\item[G2] Identity element: $\\exists e \\in G: \\forall g \\in G: e + g = g + e = g $\n\t\t\\item[G3] Inverse element: $ \\forall a \\in G$, $ \\exists b \\in G : a + b = b + a = e$\n\t\\end{itemize}\n\t\n\tA group is called a commutative group (Abelian group) if we have additionally that $ \\forall a, b \\in G: a + b = b + a$ \\\\\n\t\n\t\\textbf{Examples}\n\t\n\t\\begin{itemize}\n\t\t\\item $(\\Re^n, +)$: This can be thought of as an $n$-dimensional vector with addition as the associated operation. The addition of three vectors can be done in any order and is thus associative. The identity element in this case is the zero vector. The inverse element is the negative of each element. Thus this combination forms a group. \n\t\t\n\t\t\\item $(\\Re^+, .)$: This is the set of positive real numbers with multiplication as the associated operation. This also forms a group. \n\t\t\n\t\t\\item $(\\Re^-, .)$: This is set of negative real numbers with associated operation as multiplication. It does not form a group, since multiplication of two negative real numbers gives us a positive real number and that is out of the set considered. We can also say that the set of negative real numbers is not closed with respect to multiplication. \n\t\t\n\t\\end{itemize}\n\n\t\\begin{definition}\n\t\tA set $F$ with two operation $ (+ , \\cdot) : F \\times F \\rightarrow F$ is called a field if the following properties hold: \n\t\\end{definition}\n\t\n\t\\begin{itemize}\n\t\t\\item[F1] $ (F, +) $ is a commutative group with identity element 0.\n\t\t\\item[F2] $(F \\setminus\\{0\\}, \\cdot)$ is a commutative group with identity element 1. \n\t\t\\item[F3] Distributivity: $\\forall a, b, c \\in F: a \\cdot (b + c) = a \\cdot b + a \\cdot c$\n\t\\end{itemize}\n\n\tThe two most common fields are the ral numbers $(\\Re, +, \\cdot)$ and complex numbers $(\\mathbb{C}, +, \\cdot)$ with defined addition and multiplication.\n\t\n\t\\begin{definition}\n\t\tLet $F$ be a field with identity elements 0 and 1. A vector space over the field $F$ is a set $V$ with a mapping: $ (+) : V \\times V \\rightarrow V$ (vector addition) and a mapping $(\\cdot) : F \\times V \\rightarrow V$ (scalar multiplication) such that: \n\t\\end{definition}\n\n\t\\begin{itemize}\n\t\t\\item[V1] $(V, +)$ is a commutative group.\n\t\t\\item[V2] Multiplicative identity: $\\forall v \\in V: 1 \\cdot v = v$\n\t\t\\item[V3] Distributive property: $\\forall a, b \\in F$ and $ \\forall u, v \\in V$\n\t\t\t\\subitem $a \\cdot (u + v) = a \\cdot u + a \\cdot v$\n\t\t\t\\subitem $(a + b)u = a \\cdot u + b \\cdot u $ \t\n\t\\end{itemize}\n\n\tElements of $V$ are called vectors and elements of $F$ are called scalars. Depending on whether the field is real or complex we call the space as real vector space or complex vector space. \\\\\n\t\n\t\\textbf{Examples}\n\t\n\t\\begin{itemize}\n\t\t\n\t\t\\item $\\Re^n$ with standard operations of adding vectors and multiplying vectors with a scalar. \n\t\t\\item Function spaces: These are spaces which consists of functions. And essentially the whole field of functional analysis exploits the fact if you group them in a vector space, there are many properties that you can find about functions without even explicitly looking at what type of functions you are talking about. \n\t\t\\subitem $\\Re^\\chi$ : $\\{f: \\chi \\rightarrow \\Re\\}$ the space of all real valued functions on a set $\\chi$. No we define the two operations: \n\t\t\\subitem $ + : \\Re^\\chi \\times \\Re^\\chi \\rightarrow \\Re^\\chi$ , $(f + g)(x) := f(x) + g(x)$\n\t\t\\subitem $\\cdot : \\Re \\times \\Re^\\chi \\rightarrow \\Re^\\chi, (\\lambda \\cdot f)(x) := \\lambda \\cdot (f(x))$ \\\\\n\t\tThen $(\\Re^\\chi, +, \\cdot)$ is a vector space.\n\t\\end{itemize}", "meta": {"hexsha": "1bab9f875febbec15859019d018a058f3ecfd3b4", "size": 4013, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter-1-vector-spaces.tex", "max_stars_repo_name": "agupta54/maths-for-ml", "max_stars_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter-1-vector-spaces.tex", "max_issues_repo_name": "agupta54/maths-for-ml", "max_issues_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter-1-vector-spaces.tex", "max_forks_repo_name": "agupta54/maths-for-ml", "max_forks_repo_head_hexsha": "c5e54f14e4a24a389d31a613c34c7ef40e2bc0d1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 62.703125, "max_line_length": 351, "alphanum_fraction": 0.6837777224, "num_tokens": 1198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9621075722839015, "lm_q2_score": 0.8791467643431002, "lm_q1q2_score": 0.8458337591233874}} {"text": "\n By \\textbf{Taylors Formula}, we have for $t,t_0 \\in I$:\n \n \\begin{equation}\n \\label{eq:taylor:n}\n \\Vector{r}(t)\n =\n \\Vector{r}(t_0)\n +\n \\Vector{r}'(t_0)(t-t_0)\n +\n \\ldots+\n \\frac{1}{n!} \\Vector{r}^{(n)}(t_0)(t-t_0)^n\n +\n \\Vector{\\epsilon}_n(t)\n \\end{equation}\n \n In fact, Taylors Formula ensures, that for $t>t_0$, $\\exists \\xi \\in [t_0,t]$, so that:\n \n \\[\n |\\Vector{\\epsilon}_n(t)|\n \\leq \n \\frac{1}{(n+1)!}\n |\\Vector{r}^{(n+1)}(\\xi)|(t-t_0)^{n+1}\n \\]\n \nHence, for the \\emph{Error Vector}, $\\Vector{\\epsilon}(t)$, we have:\n \n\\begin{equation}\n \\lim_{t\\rightarrow t_0} \\frac{\\Vector{\\epsilon}_n(t)}{ (t-t_0)^n }\n \\label{eq:taylor:err:n}\n =\n \\Vector{0}\n\\end{equation}\n \n\\subsection{First Order Aproximation}\ninput{Introduction/First}\nDeriving:\n\n\\[\n v(t)=\\sqrt{ x'(t)^2+y'(t)^2},\n\\]\n\nwe observe:\n\n\\[\n v'(t)\n =\n \\frac{x'(t)+y'(t)}{ \\sqrt{ x'(t)^2+y'(t)^2} }\n =\n \\frac{x'(t)+y'(t)}{ v }\n\\]\n\n\n\\subsection{Second Order Aproximation}\n\\input{Introduction/Second}\n \n\n ", "meta": {"hexsha": "0e37446cea83c5c7919fb12a1fa1ba0169539fb4", "size": 985, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Oids/Introduction/Taylor.tex", "max_stars_repo_name": "olesmith/SmtC", "max_stars_repo_head_hexsha": "dfae5097f02192b60aae05b9d02404fcfe893be3", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Oids/Introduction/Taylor.tex", "max_issues_repo_name": "olesmith/SmtC", "max_issues_repo_head_hexsha": "dfae5097f02192b60aae05b9d02404fcfe893be3", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Oids/Introduction/Taylor.tex", "max_forks_repo_name": "olesmith/SmtC", "max_forks_repo_head_hexsha": "dfae5097f02192b60aae05b9d02404fcfe893be3", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.6949152542, "max_line_length": 88, "alphanum_fraction": 0.5654822335, "num_tokens": 422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308165850442, "lm_q2_score": 0.9059898102301019, "lm_q1q2_score": 0.8456788083808133}} {"text": "\n\\subsection{Transposition and conjugation}\n\n\\subsubsection{Transposition}\n\nA matrix of dimensions \\(m*n\\) can be transformed into a matrix \\(n*m\\) by transposition.\n\n\\(B=A^T\\)\n\n\\(b_{ij}=a{ji}\\)\n\n\\subsubsection{Transpose rules}\n\n\\((M^T)^T=M\\)\n\n\\((AB)^T=B^TA^T\\)\n\n\\((A+B)^T=A^T+B^T\\)\n\n\\((zM)^T=zM^T\\)\n\n\\subsubsection{Conjugation}\n\nWith conjugation we take the complex conjugate of each element.\n\n\\(B=\\overline A\\)\n\n\\(b_{ij}=\\overline a_{ij}\\)\n\n\\subsubsection{Conjugation rules}\n\n\\(\\overline {(\\overline A)}=A\\)\n\n\\(\\overline {(AB)}=(\\overline A)( \\overline B)\\)\n\n\\(\\overline {(A+B)}=\\overline A+\\overline B\\)\n\n\\(\\overline {(zM)}=\\overline z \\overline M\\)\n\n\\subsubsection{Conjugate transposition}\n\nLike transposition, but with conjucate.\n\n\\(B=A^*\\)\n\n\\(b_{ij}=\\bar{a_{ji}}\\)\n\nAlternatively, and particularly in physics, the following symbol is often used instead.\n\n\\((A^*)^T=A^\\dagger\\)\n\n", "meta": {"hexsha": "b9f12fb803696ce7bf8f432ca17eb3b27daa7f1d", "size": 884, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/algebra/linearSystems/04-06-keyResults.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/algebra/linearSystems/04-06-keyResults.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/algebra/linearSystemsOperations/04-04-keyResults.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.0, "max_line_length": 89, "alphanum_fraction": 0.6628959276, "num_tokens": 297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947117065459, "lm_q2_score": 0.8947894731166139, "lm_q1q2_score": 0.8455713201858868}} {"text": "\n\\subsection{Infinitum and supremum}\n\n\\subsubsection{Infinitum}\n\nConsider a subset \\(S\\) of a partially ordered set \\(T\\).\n\nThe infinitum of \\(S\\) is the greatest element in \\(T\\) that is less than or equal to all elements in \\(S\\).\n\nFor example:\n\n\\(\\inf [0,1]=0\\)\n\n\\(\\inf (0,1)=0\\)\n\n\\subsubsection{Supremum}\n\nThe supremum is the opposite: the smallest element in \\(T\\) which is greater than or equal to all elements in \\(S\\).\n\n\\(\\sup [0,1]=1\\)\n\n\\(\\sup (0,1)=1\\)\n\n\\subsubsection{Max and min}\n\nIf the infinitum of a set \\(S\\) is in \\(S\\), then the infinimum is the minimum of set \\(S\\). Otherwise, the minimum is not defined.\n\n\\(\\min [0,1]=0\\)\n\n\\(\\min (0,1)\\) isn't defined.\n\nSimilarly:\n\n\\(\\max [0,1]=1\\)\n\n\\(\\max (0,1)\\) isn't defined.\n\n", "meta": {"hexsha": "6954b04687782b5d56b1c72994bda7b0aae7df8a", "size": 736, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/orderingInfinite/01-03-infinitum.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/orderingInfinite/01-03-infinitum.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/orderingInfinite/01-03-infinitum.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.3684210526, "max_line_length": 131, "alphanum_fraction": 0.6426630435, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813463747182, "lm_q2_score": 0.8840392893839085, "lm_q1q2_score": 0.845125070113378}} {"text": "\\subsection{Complex Numbers}\r\n\\begin{definition}\r\n\t$i$ is called the imaginary unit. It's defined by $i^2 = -1$.\r\n\\end{definition}\r\n\r\n\r\n\\noindent\r\nThe set of complex numbers ($\\mathbb{C}$) is an extension of the real numbers. Complex numbers have the form $z = \\alpha + \\beta i$, where $\\alpha$ and $\\beta$ are real numbers. The $\\alpha$ part of $z$ is called the real part, so $\\Re(z) = \\alpha$. The $\\beta$ part of $z$ is called the imaginary part, so $\\Im(z) = \\beta i$.\\\\\r\n\r\n\\noindent\r\nOften, complex numbers are visualized as points or vectors in a 2D plane, called the complex plane, where $\\alpha$ is the x-component, and $\\beta$ is the y-component. Thinking of complex numbers like points helps us define the magnitude of complex numbers and compare them. Since a point $(x,y)$ has a distance $\\sqrt{x^2+y^2}$ from the origin, we can say the magnitude of $z$, $\\lvert z \\rvert$ is $\\sqrt{\\alpha^2 + \\beta^2}$. Thinking of complex numbers like vectors helps us understand adding two complex numbers, since you just add the components like vectors.\\\\\r\n\r\n\\noindent\r\nA common operation on complex numbers is the complex conjugate. The complex conjugate of $z = \\alpha + \\beta i$ is $\\overline{z} = \\alpha - \\beta i$. $z$ and $\\overline{z}$ are called a conjugate pair.\\\\\r\n\r\n\\noindent\r\nConjugate pairs have the following properties.\r\nLet $z, w \\in \\mathbb{C}$.\r\n\\begin{align*}\r\n\t\\overline{z \\pm w} &= \\overline{z} \\pm \\overline{w} \\\\\r\n\t\\overline{zw} &= \\overline{z}\\overline{w} \\\\\r\n\t\\overline{z} &= z \\Leftrightarrow z \\in \\mathbb{R} \\\\\r\n\tz\\overline{z} &= \\lvert z \\rvert^2 = \\lvert \\overline{z} \\rvert^2 \\\\\r\n\t\\overline{\\overline{z}} &= z \\\\\r\n\t\\overline{z}^n &= \\overline{z^n} \\\\\r\n\tz^{-1} &= \\frac{\\overline{z}}{\\lvert z \\rvert^2} \r\n\\end{align*}\r\n", "meta": {"hexsha": "863e6eef3e8b77987cff834116e2c9a4179d08b6", "size": 1750, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "common/algebraPreCalc/complexNumbers.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "common/algebraPreCalc/complexNumbers.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "common/algebraPreCalc/complexNumbers.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 62.5, "max_line_length": 567, "alphanum_fraction": 0.676, "num_tokens": 551, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813476288299, "lm_q2_score": 0.8840392863287585, "lm_q1q2_score": 0.8451250683013956}} {"text": "We have already seen that given any logical expression $L$ with $n$ variables we can form a truth table with precisely $2^n$ rows documenting the output of $L$ when it is evaluated at each possible input. Now we want to answer the reverse question: if we have a table $Y$ of the format of a truth table with $2^n$ rows documenting some possible output with each input of $n$ variables, then is there a logical expression involving all $n$ variables and some of the binary logical operators introduced earlier for which its truth table is exactly the table $Y$? It turns out that this answer is yes, and in this section we will see why.\n\n\\subsection{The $\\land$ as an indicator function}\n\nSuppose that $x_1, \\dots, x_n$ are our boolean variables under consideration. Then the logical expression \n\\[L \\equiv x_1 \\land x_2 \\land \\cdots \\land x_n\\] evaluates to $T$ only if every variable $x_k$ is set to $T$. So $L$ can be seen as an indicator function which is true on only one possible input of logical variables. But what if I wanted an expression which evaluates to $T$ only if every variable except $x_1$ is set to $T$? This is not too much of a problem either, since the expression\n\\[K \\equiv (\\shortsim x_1) \\land x_2 \\land\\cdots \\land x_n\\] evaluates to $T$ in this case and $F$ otherwise. With these two examples it is clear how to make an ``indicator function'' which evaluates to true given one assignment of random variables and false otherwise. Simply take the expression\n%I need to think up better notation than this here..\n\\[\\bigwedge\\limits_{x_k \\rightarrow F}(\\shortsim x_k) \\land \\bigwedge\\limits_{x_j \\rightarrow T}x_j\\]\nwhere the big $\\land$ represents a logical and over all the variables in question where we want the variables to be $F$ or $T$. It is clear that this expression evaluates to $T$ only one one choice of variable assignment.\n\n\\subsection{The $\\lor$ as a join function}\n\nSo far we have demonstrated how to represent any truth table $Y$ with exactly one row of the table evaluating to $T$ as a logical expression. However, what about the rest? The remaining questions can be answered once we consider the act of conjoining equations using the $\\lor$ operator.\n\nFirst consider the logical expression $L$ in the previous subsection. For any other logical expression $M$, consider the logical expression $L \\lor M$. One thing we can say about $L \\lor M$ is that it evaluates to true when every variable $x_k$ is set to $T$. We don't know that much about its evaluation at any of the other variables though. If instead we considered the logical expression $L \\lor K$, where $K$ was defined in the previous section, then we see that $L \\lor K$ evaluates to $T$ at exactly two assignments, precisely those that made $L$ and $K$ evaluate to $T$.\n\nUsing these two concepts it is now clear how to represent any truth table $Y$ using a logical expression. First, consider for which assignments of variables $Y$ evaluates to $T$. For these assignments create indicator $\\land$ expressions $L_j$ which evaluate to true only when we have that specific variable assignment. Finally, take all such expressions $L_j$ and conjoin them with $\\lor$ expressions to create a final expression. \n\n\\begin{example}\nConsider the following truth table:\n\n\\begin{table}[h]\n\\centering\n\\begin{tabular}{|l|l|l|}\n\\hline\n$p$ & $q$ & ??\\\\ \\hline\n$T$ & $T$ & $T$ \\\\ \\hline\n$T$ & $F$ & $F$ \\\\ \\hline\n$F$ & $T$ & $T$ \\\\ \\hline\n$F$ & $F$ & $F$ \\\\ \\hline\n\\end{tabular}\n\\end{table}\n\nWe will create a logical expression whose truth table is the same as this truth table. Note that the this table only evaluates to true when $p \\equiv T, q \\equiv T$, and $p \\equiv F, q \\equiv T$. The associated indicator $\\land$ functions for these assignments are $p \\land q$ and $(\\shortsim p) \\land q$. Hence the final expression whose truth table is equal to the above truth table is\n\\[(p \\land q) \\lor ((\\shortsim p) \\land q).\\]\n\\end{example}\n\nOne can see that the process described above will always generate a logical expression whose truth table is equivalent to the given truth table. To see this, we observe that the expression we generate is several indicator expressions linked up with the $\\lor$ operator. If any one of these is true, then the whole expression is true. Conversely, if an assignment of variables goes to false in the original truth table then it does not match any of the indicator expressions, so the whole logical expression evaluates to false. The final expression that we obtain is said to be in \\textbf{disjunctive normal form}.\n\n\\subsection{Using $\\lor$ as an indicator function instead}\n\nNote that given $n$ boolean variables $x_1, \\dots, x_n$, the expression\n\\[x_1 \\lor \\cdots \\lor x_n\\] evaluates to $T$ for all variable assignments except for the assignment where every boolean variable is assigned $F$. Using similar ideas to the first subsection, we can create indicator logical expressions where every assignment evaluates to true except for one. To create a general expression we can take such indicator expressions and join them together with $\\land$ taking in mind that any logical expression $L$ will satisfy \n\\[L \\land F \\equiv F.\\]\nThe resulting expression obtained is said to be in \\textbf{conjunctive normal form}.", "meta": {"hexsha": "71a9062dd28aab3d54ce0ff8f68bc5e4e8649ec0", "size": 5238, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Ch1/dnf_cnf.tex", "max_stars_repo_name": "jonlin1000/discr_math", "max_stars_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-22T03:31:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-14T02:26:40.000Z", "max_issues_repo_path": "Ch1/dnf_cnf.tex", "max_issues_repo_name": "jonlin1000/discr_math", "max_issues_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch1/dnf_cnf.tex", "max_forks_repo_name": "jonlin1000/discr_math", "max_forks_repo_head_hexsha": "f18413d1eb0ed598b325e5cd8052fcc571337926", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 113.8695652174, "max_line_length": 635, "alphanum_fraction": 0.7569683085, "num_tokens": 1290, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133557169236, "lm_q2_score": 0.8991213799730775, "lm_q1q2_score": 0.8450961934473264}} {"text": "Suppose the discretization of a boundary value problem, such as the Poisson equation, leads to the matrix equation\n\\begin{align*}\nuA + Bu = f,\n\\end{align*}\nthat needs to be solved for $u$. Here $u$ is $n \\times m$, $A$ is $m \\times m$, $B$ is $n \\times n$, and $f$ is $n \\times m$.\n\n\\begin{questions}\n\n\\question{Assuming both $A$ and $B$ are non-defective matrices, with $A = V_A \\Lambda_AV_A^{-1}$ and $B = V_B \\Lambda_BV_B^{-1}$, show that the solution $u$ is given by $u = V_B UV_A^{-1}$, where\n\\begin{align*}\nU_{i,j} = \\frac{F_{i,j}}{\\alpha_j + \\beta_i},\n\\end{align*}\n$F = V_B^{-1}fV_A$, and $\\alpha_k$ and $\\beta_k$ are the diagonal entries of $\\Lambda_A$ and $\\Lambda_B$ respectively.\n }\n\n\\begin{solution}\n\nWe begin with,\n\\begin{align*}\n& uA + Bu = f \\\\\n\\Rightarrow ~& uV_A \\Lambda_AV_A^{-1} + V_B \\Lambda_BV_B^{-1} u = f~.\n\\end{align*}\nWe then multiple the entire equation by $V_B^{-1}$ from the left and $V_A$ from the right to obtain,\n\\begin{align*}\nV_B^{-1}uV_A\\Lambda_A + \\Lambda_B V_B^{-1} u V_A = V_B^{-1} f V_A~.\n\\end{align*}\nThen let $U = V_B^{-1}uV_A$ and $F = V_B^{-1} f V_A$ so that,\n\\begin{align*}\nU\\Lambda_A + \\Lambda_B U = F~.\n\\end{align*}\nWhich in matrix form,\n\\begin{align*}\n&\\begin{bmatrix}\n\\tilde{u}_{11}& \\cdots & \\tilde{u}_{1m} \\\\\n\\tilde{u}_{21}& \\cdots & \\tilde{u}_{2m} \\\\\n\\vdots& ~ & \\vdots \\\\\n\\tilde{u}_{n1}& \\cdots & \\tilde{u}_{nm}\n\\end{bmatrix} \\begin{bmatrix}\n\\alpha_1 & 0 & \\cdots & 0 \\\\\n0 & \\alpha_2 & ~ & \\vdots \\\\\n\\vdots & ~& \\ddots & ~ \\\\\n0 & \\cdots & 0 & \\alpha_m\n\\end{bmatrix} + \\begin{bmatrix}\n\\beta_1 & 0 & \\cdots & 0 \\\\\n0 & \\beta_2 & ~ & \\vdots \\\\\n\\vdots & ~& \\ddots & ~ \\\\\n0 & \\cdots & 0 & \\beta_m\n\\end{bmatrix}\\begin{bmatrix}\n\\tilde{u}_{11}& \\cdots & \\tilde{u}_{1m} \\\\\n\\tilde{u}_{21} & \\cdots & \\tilde{u}_{2m} \\\\\n\\vdots& ~ & \\vdots \\\\\n\\tilde{u}_{n1} & \\cdots & \\tilde{u}_{nm}\n\\end{bmatrix} = \\begin{bmatrix}\n\\tilde{f}_{11} & \\cdots & \\tilde{f}_{1m} \\\\\n\\tilde{f}_{21} & \\cdots & \\tilde{f}_{2m} \\\\\n\\vdots & ~ & \\vdots \\\\\n\\tilde{f}_{n1} & \\cdots & \\tilde{f}_{nm}\n\\end{bmatrix}~,\n\\end{align*}\nshows us,\n\\begin{align*}\n \\begin{cases} \\tilde{u}_{11}\\alpha_1 + \\beta_1 \\tilde{u}_{11} = \\tilde{f}_{11} \\\\ \\tilde{u}_{12}\\alpha_2 + \\beta_1 \\tilde{u}_{12} = \\tilde{f}_{12} \\\\ \\vdots \\end{cases} \\Rightarrow ~U_{i,j} = \\frac{F_{i,j}}{\\alpha_j + \\beta_i}~.\n\\end{align*}\nThen, to get back our solution, we use $u = V_B U V_A^{-1}$.\n\n\\end{solution}\n\n\\question{Using part (a), solve the Poisson equation $\\Delta u = \\sin(x)\\cos(100y)$ on $[0,1] \\times [0,1]$ (with zero Dirichlet boundary conditions) using 100 points in the $x$ direction and 300 in the $y$ direction. Estimate the accuracy of your solution.\n}\n\n\\begin{solution}\n\nFollowing the exact scheme above, we obtain a solution for $u$ depicted in the figure below,\n\n\\begin{figure}[H]\n\\center{\\includegraphics[scale=.5]{P2F2.eps}}\n\\caption{Surface of $u$}\n\\end{figure}\n\nThe error, found by comparing $uD2A + D2Bu$ and $f$, where $D2A$ and $D2B$ are the centered finite difference matrices for $x$ and $y$ respectively, is $2.2451e-12$. \n\n\\end{solution}\n\n\\end{questions}\n\n\\subsubsection*{MATLAB}\n\n \\begin{verbatim}\n% % Laplacian with zero BCs\nm = 100;\nhA = 1/(m-1);\nD2A = (gallery('tridiag',m,1,-2,1))/(hA^2);\n[eVA,evalA] = eig(full(D2A)); lamA = diag(evalA);\nn = 300;\nhB = 1/(n-1);\nD2B = (gallery('tridiag',n,1,-2,1))/(hB^2);\n[eVB,evalB] = eig(full(D2B)); lamB = diag(evalB);\n\ny = linspace(0,1,300);\nx = linspace(0,1,100);\n[xx,yy] = meshgrid(x,y);\nf = sin(xx).*cos(100.*yy);\n\nF = eVB'*f*eVA;\n\nU = zeros(size(f));\n\nfor j = 1:m\n U(:,j) = F(:,j)./(lamB + lamA(j));\nend\n\nu = eVB*U*eVA';\n\nsol = u*D2A' + D2B*u;\n\nerr = norm(sol - f,inf);\n\nfigure\nplot(xx,sol(1,:),'r*',xx,f(1,:),'bo'); hold on\nplot(xx,sol(2,:),'g*',xx,f(2,:),'mo')\nplot(xx,sol(end,:),'k*',xx,f(end,:),'yo')\ngrid on\n\nfigure\nsurf(xx,yy,u,'EdgeColor','none')\n\\end{verbatim}\n", "meta": {"hexsha": "fc7c99f2ed0f271e0d6dc8ccc1dad419e482eb48", "size": 3823, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Year_1/ComputationalMethods/Homework 6/Latex/texfiles/problem2.tex", "max_stars_repo_name": "fjcasti1/Courses", "max_stars_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Year_1/ComputationalMethods/Homework 6/Latex/texfiles/problem2.tex", "max_issues_repo_name": "fjcasti1/Courses", "max_issues_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Year_1/ComputationalMethods/Homework 6/Latex/texfiles/problem2.tex", "max_forks_repo_name": "fjcasti1/Courses", "max_forks_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1023622047, "max_line_length": 257, "alphanum_fraction": 0.6149620717, "num_tokens": 1539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133531922388, "lm_q2_score": 0.8991213718636754, "lm_q1q2_score": 0.845096183555193}} {"text": "\n\n\\section{Computer exercises for the lab}\n\nThis week is a good time for\n\\begin{itemize}\n\\item[(a)] making sure you are comfortable with the mathematics behind matrices as well as:\n\\item[(b)] making sure you are comfortable with the matrix operators in R. \n\\item[(c)] Check that you are very very sure you can subscript R matrices, i.e. use things such as \\text{[,1]} to select column 1, \\text{[,-1]} to select everything \\emph{except} column 1, and \\text{[,2:3]} to select columns 2 and 3.\n\\end{itemize}\n\nAlthough we will use in built multivariate analysis functions in R, you should consider checking you understand the techniques by using R as a matrix calculator.\n \n\\begin{enumerate}\n\n\\item Find (where possible) the determinants and the inverse of the following matrices:\n\n$C_{1} = \\left[ \\begin {array}{cc} 4& 4\\\\\\noalign{\\medskip} 4& 4\\end {array} \\right]$, $C_{2} = \\left[ \\begin {array}{cc} 4& 4.001\\\\\\noalign{\\medskip} 4.001& 4.002\\end {array} \\right]$ and $C_{3} = \\left[ \\begin {array}{cc} 4& 4.001\\\\\\noalign{\\medskip} 4.001& 4.002001\\end {array} \\right] $\n\nVery briefly comment on the magnitude of the difference between $C_{2}^{-1}$ and $C_{3}^{-1}$ given the only difference between $C_{2}$ and $C_{2}$ amounts to a difference of $0.000001$ in the bottom right position.\n\n\\begin{Schunk}\n\\begin{Sinput}\n> A <- matrix(c(4, 4, 4, 4), 2, 2)\n> A\n> det(A)\n> try(solve(A))\n> B <- matrix(c(4, 4.001, 4.001, 4.002), 2, 2)\n> B\n> det(B)\n> solve(B)\n> C <- matrix(c(4, 4.001, 4.001, 4.002001), 2, 2)\n> C\n> det(C)\n> solve(C)\n\\end{Sinput}\n\\end{Schunk}\n\n\n\\begin{itemize}\n \\item What's going on here?\n\\end{itemize}\n\n\\textit{Note that A is singular, the determinant is zero and it can't be inverted. Also note that the inverses of B and C are very very different - but this is something of a pathological example}\n\n\n\\item Matrix partitioning. Consider Sterling's financial data held in the R object LifeCycleSavings (see \\verb+?LifeCycleSavings+). To make life a little easier, reorder the columns using \\texttt{X <- LifeCycleSavings[,c(2,3,1,4,5)]}.\n \n\n\\begin{itemize}\n\\item Find the correlation matrix of \\texttt{X} (longhand, using the centering matrix), call this matrix \\texttt{R}\n\n\n\\begin{Schunk}\n\\begin{Sinput}\n> data(LifeCycleSavings)\n> X <- LifeCycleSavings[, c(2, 3, 1, 4, 5)]\n> R <- cor(X)\n> R\n\\end{Sinput}\n\\end{Schunk}\n\n\n\\item Partition \\textit{R = cov(X)} following the scheme below such that $\\boldsymbol{R_{11}}$ is a $2 \\times 2$ matrix containing the covariance of \\texttt{pop15} and \\texttt{pop75}, and $\\boldsymbol{R_{22}}$ contains the covariance of \\texttt{sr}, \\texttt{dpi} and \\texttt{ddpi}\n\n\\begin{displaymath}\n\\boldsymbol{R} = \\left( \\begin{array}{l|l} \\boldsymbol{R_{11}} & \\boldsymbol{R_{12}} \\\\ \\hline \\boldsymbol{R_{21}} & \\boldsymbol{R_{22}} \\end{array} \\right) \n\\end{displaymath}\n\nYou should find for example that $\\boldsymbol{R_{11}}$ is given by:\n % latex table generated in R 2.3.1 by xtable 1.3-2 package\n% Wed Nov 15 22:15:30 2006\n\\begin{table}[ht]\n\\begin{center}\n\\begin{tabular}{rrr}\n\\hline\n & pop15 & pop75 \\\\\n\\hline\npop15 & 83.75 & $-$10.73 \\\\\npop75 & $-$10.73 & 1.67 \\\\\n\\hline\n\\end{tabular}\n\\end{center}\n\\end{table}\n\n\\begin{Schunk}\n\\begin{Sinput}\n> R11 <- R[1:2, 1:2]\n> R12 <- R[1:2, 3:5]\n> R21 <- R[3:5, 1:2]\n> R22 <- R[3:5, 3:5]\n> R11\n> R22\n> R21\n> R12\n> t(R21)\n\\end{Sinput}\n\\end{Schunk}\n\n\n\\item Find the matrix $\\boldsymbol{A}$, where:\n\n\\begin{displaymath}\n\\boldsymbol{A} = \\boldsymbol{R_{22}^{-1}R_{21}R_{11}^{-1}R_{12}}\n\\end{displaymath}\n\n\n\n\\begin{Schunk}\n\\begin{Sinput}\n> A <- solve(R22) %*% R21 %*% solve(R11) %*% R12\n\\end{Sinput}\n\\end{Schunk}\n\n\n%\\begin{itemize}\n\n\\item Are $\\boldsymbol{A}$ and $\\boldsymbol{B}$ symmetric? What is the difference between symmetric and asymmetric matrices in terms of their eigenvalues and eigenvectors?\\\\\n\\textit{Note that they are both asymmetric matrices, it just so happens for these particular matrices that the eigenvalues are positive and the eigenvectors are real. This isn't always the case for asymmetric matrices!}\n\n\\item Find the eigenvalues and eigenvectors of $\\boldsymbol{A}$ and $\\boldsymbol{B}$ then find the square roots of the eigenvalues. \n\n\n\\begin{Schunk}\n\\begin{Sinput}\n> eigen(B)\n> sqrt(eigen(A)$values)\n> sqrt(eigen(B)$values)\n\\end{Sinput}\n\\end{Schunk}\n\n\n\\item Do you notice any similarities between the first two eigenvalues from either matrix?\\\\\n\\textit{Note that the square roots of the eigen values are identical.}\n\\end{itemize}\n\n\\item Revisit the \\texttt{wines} data in the \\texttt{Flury} package. Consider only Y1, Y5, Y6, Y8 and Y9, use matrix algebra to find the means, correlation and covariance of these data. Compare the eigenvalues and eigenvectors, and the determinants and inverse you get from the covariance matrix and the correlation matrix.\\\\\n\n\n \n \n\\end{enumerate} \n\n\n\\section{Summary of week 2}\n\n\\fbox{\\parbox[c]{0.9\\textwidth}{\\color{blue}\n \n\\begin{itemize}\n\\item We have revised, and are comfortable with matrix multiplication, matrix inverse, (normalised) eigenvalues and eigenvectors. We can center and scale matrices. We can do this by hand and in R.\n\\item We are also comfortable using R as a matrix calculator if and when we wish.\n\\end{itemize}\n}}\n", "meta": {"hexsha": "110e531b8ea41d5ba04413d3cb4f2fdf10aa4ddf", "size": 5207, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "newworksheet/week2matrix.tex", "max_stars_repo_name": "phewson/mvstats", "max_stars_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "newworksheet/week2matrix.tex", "max_issues_repo_name": "phewson/mvstats", "max_issues_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2020-08-28T16:37:22.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-28T16:49:11.000Z", "max_forks_repo_path": "newworksheet/week2matrix.tex", "max_forks_repo_name": "phewson/mvstats", "max_forks_repo_head_hexsha": "f39ab1c1b97c89e26c708bd6d532fe13c063a95c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8116883117, "max_line_length": 329, "alphanum_fraction": 0.7015555982, "num_tokens": 1715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632916317103, "lm_q2_score": 0.9111797045849583, "lm_q1q2_score": 0.8449946101119163}} {"text": "\\lab{Introduction to Matplotlib}{Introduction to Matplotlib}\n\\label{lab:Matplotlib}\n\\objective{\nMatplotlib is the most commonly used data visualization library in Python. Being able to visualize data helps to determine patterns, to communicate results, and is a key component of applied and computational mathematics.\nIn this lab we introduce techniques for visualizing data in 1, 2, and 3 dimensions.\nThe plotting techniques presented here will be used in the remainder of the labs in the manual.\n}\n\n\\section*{Line Plots} % =======================================================\n\nRaw numerical data is rarely helpful unless it can be visualized.\nThe quickest way to visualize a simple 1-dimensional array is via a \\emph{line plot}.\nThe following code creates an array of outputs of the function $f(x) = x^2$, then visualizes the array using the \\li{matplotlib} module.\\footnote{Like NumPy, Matplotlib is \\emph{not} part of the Python standard library, but it is included in most Python distributions.}\n\n\\begin{lstlisting}\n>>> import numpy as np\n>>> from matplotlib import pyplot as plt\n\n>>> y = np.arange(-5,6)**2\n>>> y\narray([25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25])\n\n# Visualize the plot.\n>>> plt.plot(y) # Draw the line plot.\n<<[]>>\n>>> plt.show() # Reveal the resulting plot.\n\\end{lstlisting}\n\nThe result is shown in Figure \\ref{fig:basic1}.\nJust as \\li{np} is a standard alias for NumPy, \\li{plt} is a standard alias for \\li{matplotlib.pyplot} in the Python community.\n\nThe call \\li{plt.plot(y)} creates a figure and draws straight lines connecting the entries of \\li{y} relative to the $y$-axis.\nThe $x$-axis is (by default) the index of the array, which in this case is the integers from $0$ to $10$.\nCalling \\li{plt.show()} then displays the figure.\n\n\\begin{figure}[H] % plt.plot(y) compared to plt.plot(x,y).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/basic1.pdf}\n \\caption{\\li{plt.plot(y)} uses the indices of\\\\the array for the $x$-axis.}\n \\label{fig:basic1}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/basic2.pdf}\n \\caption{\\li{plt.plot(x,y)} specifies both the\\\\domain and the range.}\n \\label{fig:basic2}\n\\end{subfigure}\n\\caption{Plots of $f(x) = x^2$ over the interval $[-5,5]$.}\n\\end{figure}\n\n\\begin{problem} % Law of Large Numbers / NumPy review.\nNumPy's \\li{random} module has tools for sampling from probability distributions.\nFor instance, \\li{np.random.normal()} draws samples from the normal (Gaussian) distribution.\nThe \\li{size} parameter specifies the shape of the resulting array.\n\\begin{lstlisting}\n>>> np.random.normal(size=(2,3)) # Get a 2x3 array of samples.\narray([[ 1.65896515, -0.43236783, -0.99390897],\n [-0.35753688, -0.76738306, 1.29683025]])\n\\end{lstlisting}\n%\nWrite a function that accepts an integer $n$ as input.\n\\begin{enumerate}\n\\item Use \\li{np.random.normal()} to create an $n\\times n$ array of values randomly sampled from the standard normal distribution.\n\\item Compute the mean of each row of the array.\n\\\\(Hint: Use \\li{np.mean()} and specify the \\li{axis} keyword argument.)\n\\item Return the variance of these means.\n\\\\(Hint: Use \\li{np.var()} to calculate the variance).\n\\end{enumerate}\nDefine another function that creates an array of the results of the first function with inputs $n = 100,\\ 200,\\ \\ldots,\\ 1000$.\nPlot (and show) the resulting array.\n% This result illustrates one version of the \\emph{law of large numbers}.\n\\end{problem}\n\n\\subsection*{Specifying a Domain} % -----------------------------------------\n\nAn obvious problem with Figure \\ref{fig:basic1} is that the $x$-axis does not correspond correctly to the $y$-axis for the function $f(x) = x^2$ that is being drawn.\nTo correct this, define an array \\li{x} for the domain, then use it to calculate the image \\li{y = f(x)}.\nThe command \\li{plt.plot(x,y)} plots \\li{x} against \\li{y} by drawing a line between the consecutive points \\li{(x[i], y[i])}.\n% Note that the arrays must have the same number of elements to be compatible.\n\nAnother problem with Figure \\ref{fig:basic1} is its poor resolution: the curve is visibly bumpy, especially near the bottom of the curve.\nNumPy's \\li{linspace()} function makes it easy to get a higher-resolution domain.\nRecall that \\li{np.arange()} return an array of evenly-spaced values in a given interval, where\n\n% NOTE: the \\noindent is to fix a page break problem in PythonEssentials.pdf.\n\n\\noindent the \\textbf{spacing} between the entries is specified.\nIn contrast, \\li{np.linspace()} creates an array of evenly-spaced values in a given interval where the \\textbf{number of elements} is specified.\n\n\\begin{lstlisting}\n# Get 4 evenly-spaced values between 0 and 32 (including endpoints).\n>>> np.linspace(0, 32, 4)\narray([ 0. , 10.66666667, 21.33333333, 32. ])\n\n# Get 50 evenly-spaced values from -5 to 5 (including endpoints).\n>>> x = np.linspace(-5, 5, 50)\n>>> y = x**2 # Calculate the range of f(x) = x**2.\n>>> plt.plot(x, y)\n>>> plt.show()\n\\end{lstlisting}\n\nThe resulting plot is shown in Figure \\ref{fig:basic2}.\nThis time, the $x$-axis correctly matches up with the $y$-axis.\nThe resolution is also much better because \\li{x} and \\li{y} have $50$ entries each instead of only $10$.\n\nSubsequent calls to \\li{plt.plot()} modify the same figure until \\li{plt.show()} is executed, which displays the current figure and resets the system.\nThis behavior can be altered by specifying separate figures or axes, which we will discuss shortly.\n\n\\begin{info} % Interactive Mode.\nPlotting can seem a little mystical because the actual plot doesn't appear until \\li{plt.show()} is executed.\nMatplotlib's \\emph{interactive mode} allows the user to see the plot be constructed one piece at a time.\nUse \\li{plt.ion()} to turn interactive mode on and \\li{plt.ioff()} to turn it off.\nThis is very useful for quick experimentation.\nTry executing the following commands in IPython:\n\n\\begin{lstlisting}\ng> import numpy as np\ng> from matplotlib import pyplot as plt\n\n# Turn interactive mode on and make some plots.\ng> plt.ion()\ng> x = np.linspace(1, 4, 100)\ng> plt.plot(x, np.log(x))\ng> plt.plot(x, np.exp(x))\n\n# Clear the figure, then turn interactive mode off.\ng> plt.clf()\ng> plt.ioff()\n\\end{lstlisting}\n\nUse interactive mode \\textbf{only} with IPython.\nUsing interactive mode in a non-interactive setting may freeze the window or cause other problems.\n\\end{info}\n\n\\begin{problem} % Plot two lines (sin() and cos()).\nWrite a function that plots the functions $\\sin(x)$, $\\cos(x)$, and $\\arctan(x)$ on the domain $[-2\\pi, 2\\pi]$ (use \\li{np.pi} for $\\pi$).\n% Call \\li{plt.xlim(-2*np.pi, 2*np.pi)} before \\li{plt.show()} to stretch the $x$-axis appropriately.\nMake sure the domain is refined enough to produce a figure with good resolution.\n\\end{problem}\n\n\\section*{Plot Customization} % ===============================================\n\n\\li{plt.plot()} receives several keyword arguments for customizing the drawing.\nFor example, the color and style of the line are specified by the following string arguments.\n%\n\\begin{table}[H] % Color and style.\n\\begin{tabular}{r|l}\n Key & Color \\\\\n \\hline\n \\li{'b'} & blue\\\\\n \\li{'g'} & green\\\\\n \\li{'r'} & red\\\\\n \\li{'c'} & cyan\\\\\n % \\li{'m'} & magenta\\\\\n % \\li{'y'} & yellow\\\\\n \\li{'k'} & black\\\\\n % \\li{'w'} & white\n\\end{tabular}\n\\qquad\n\\begin{tabular}{r|l}\n Key & Style \\\\\n \\hline\n \\li{'-'} & solid line\\\\\n \\li{'--'} & dashed line\\\\\n \\li{'-.'} & dash-dot line\\\\\n \\li{':'} & dotted line\\\\\n % \\li{'.'} & point marker\\\\\n \\li{'o'} & circle marker\\\\\n % \\li{'*'} & star marker\\\\\n % \\li{'+'} & plus marker\n\\end{tabular}\n\\end{table}\n%\nSpecify one or both of these string codes as the third argument to \\li{plt.plot()} to change from the default color and style.\nOther \\li{plt} functions further customize a figure.\n%\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{r|l}\n Function & Description\\\\\n \\hline\n % \\li{grid()} & Add grid lines\\\\\n \\li{legend()} & Place a legend in the plot\\\\\n % \\li{text()} & Add text at a given position on the plot\\\\\n \\li{title()} & Add a title to the plot\\\\\n \\li{xlim()} / \\li{ylim()} & Set the limits of the $x$- or $y$-axis\\\\\n % \\li{xticks()} & set the location of the tick marks on the x axis, returns current locations if no arguments are given\\\\\n % \\li{yticks()} & set the location of the tick marks on the y axis, returns current locations if no arguments are given\\\\\n \\li{xlabel()} / \\li{ylabel()} & Add a label to the $x$- or $y$-axis\\\\\n\\end{tabular}\n\\end{table}\n\n\\begin{lstlisting}\n>>> x1 = np.linspace(-2, 4, 100)\n>>> plt.plot(x1, np.exp(x1), 'g:', linewidth=6, label=\"Exponential\")\n>>> plt.title(\"This is the title.\", fontsize=18)\n>>> plt.legend(loc=\"upper left\") # plt.legend() uses the 'label' argument of\n>>> plt.show() # plt.plot() to create a legend.\n\n>>> x2 = np.linspace(1, 4, 100)\n>>> plt.plot(x2, np.log(x2), 'r*', markersize=4)\n>>> plt.xlim(0, 5) # Set the visible limits of the x axis.\n>>> plt.xlabel(\"The x axis\") # Give the x axis a label.\n>>> plt.show()\n\\end{lstlisting}\n%\n\\begin{figure}[H] % Figure customizations.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/custom1.pdf}\n \\label{fig:custom1}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/custom2.pdf}\n \\label{fig:custom2}\n\\end{subfigure}\n\\label{fig:custom}\n\\end{figure}\n%\n% See Appendix \\ref{mpltables} for more comprehensive lists of colors, line styles, and figure customization routines.\n%\n\\begin{problem} % Line plots with different domains but uniform style.\nWrite a function to plot the curve $f(x) = \\frac{1}{x-1}$ on the domain $[-2,6]$.\n\\begin{enumerate}\n\\item\nAlthough $f(x)$ has a discontinuity at $x=1$, a single call to \\li{plt.plot()} in the usual way will make the curve look continuous.\nSplit up the domain into $[-2,1)$ and $(1,6]$.\nPlot the two sides of the curve separately so that the graph looks discontinuous at $x=1$.\n\\item Plot both curves with a dashed magenta line.\nSet the keyword argument \\li{linewidth} (or \\li{lw}) of \\li{plt.plot()} to $4$ to make the line a little thicker than the default setting.\n\\item Use \\li{plt.xlim()} and \\li{plt.ylim()} to change the range of the $x$-axis to $[-2,6]$ and the range of the $y$-axis to $[-6, 6]$.\n\\end{enumerate}\nThe plot should resemble the figure below.\n\n\\begin{figure}[H] % Solution.\n\\includegraphics[width=.5\\textwidth]{figures/discontinuousProblem.pdf}\n\\end{figure}\n\\end{problem}\n\n\\subsection*{Figures, Axes, and Subplots} % -----------------------------------\n\nThe window that \\li{plt.show()} reveals is called a \\emph{figure}, stored in Python as a \\li{plt.Figure} object.\nA space on a figure where a plot is drawn is called an \\emph{axes}, a \\li{plt.Axes} object.\nA figure can have multiple axes, and a single program may create several figures.\nThere are several ways to create or grab figures and axes with \\li{plt} functions.\n\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{r|l}\n Function & Description\\\\\n \\hline\n \\li{axes()} & Add an axes to the current figure\\\\\n \\li{figure()} & Create a new figure or grab an existing figure\\\\\n \\li{gca()} & Get the current axes\\\\\n \\li{gcf()} & Get the current figure\\\\\n \\li{subplot()} & Add a single subplot to the current figure\\\\\n \\li{subplots()} & Create a figure and add several subplots to it\\\\\n\\end{tabular}\n\\end{table}\n\nUsually when a figure has multiple axes, they are organized into non-overlapping \\emph{subplots}.\nThe command \\li{plt.subplot(nrows, ncols, plot_number)} creates an axes in a subplot grid where \\li{numrows} is the number of rows of subplots in the figure, \\li{numcols} is the number of columns, and \\li{plot_number} specifies which subplot to modify.\nIf the inputs for \\li{plt.subplot()} are all integers, the commas between the entries can be omitted.\nFor example, \\li{plt.subplot(3,2,2)} can be shortened to \\li{plt.subplot(322)}.\n\n\\begin{figure}[H] % The layout created by subplots(23i).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{framed}\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_1.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_2.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_3.pdf}\n\\end{subfigure}\n\\\\\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_4.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_5.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.32\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_6.pdf}\n\\end{subfigure}\n\\end{framed}\n\\caption{The layout of subplots with \\li{plt.subplot(2,3,i)} (2 rows, 3 columns), where \\li{i} is the index pictured above. The outer border is the figure that the axes belong to.}\n\\label{fig:subplots-layout}\n\\end{figure}\n\n\\begin{lstlisting}\n>>> x = np.linspace(.1, 2, 200)\n# Create a subplot to cover the left half of the figure.\n>>> ax1 = plt.subplot(121)\n>>> ax1.plot(x, np.exp(x), 'k', lw=2)\n>>> ax1.plot(x, np.exp(2*x), 'b', lw=2)\n>>> plt.title(\"Exponential\", fontsize=18)\n\n# Create another subplot to cover the right half of the figure.\n>>> ax2 = plt.subplot(122)\n>>> ax2.plot(x, np.log(x), 'k', lw=2)\n>>> ax2.plot(x, np.log(2*x), 'b', lw=2)\n>>> ax2.set_title(\"Logarithmic\", fontsize=18)\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H] % The layout created by plt.subplot(23i).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{framed}\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/subplots_1.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/subplots_2.pdf}\n\\end{subfigure}\n\\end{framed}\n\\end{figure}\n\n\\begin{info}\nPlotting functions such as \\li{plt.plot()} are shortcuts for accessing the current axes on the current figure and calling a method on that \\li{Axes} object.\nCalling \\li{plt.subplot()} changes the current axis, and calling \\li{plt.figure()} changes the current figure.\nUse \\li{plt.gca()} to get the current axes and \\li{plt.gcf()} to get the current figure.\nCompare the following equivalent strategies for producing a figure with two subplots.\n\n\\begin{lstlisting}\n>>> x = np.linspace(-5, 5, 100)\n\n# 1. Use plt.subplot() to switch the current.\n>>> plt.subplot(121)\n>>> plt.plot(x, 2*x)\n>>> plt.subplot(122)\n>>> plt.plot(x, x**2)\n\n# 2. Use plt.subplot() to explicitly grab the two subplot axes.\n>>> ax1 = plt.subplot(121)\n>>> ax1.plot(x, 2*x)\n>>> ax2 = plt.subplot(122)\n>>> ax2.plot(x, x**2)\n\n# 3. Use plt.subplots() to get the figure and all subplots simultaneously.\n>>> fig, axes = plt.subplots(1, 2)\n>>> axes[0].plot(x, 2*x)\n>>> axes[1].plot(x, x**2)\n\\end{lstlisting}\n\n% Having direct access to the axes and figures as Python objects provides a great deal of flexibility for plot customization.\n% If you ever need access to the current axes for detailed customization, use \\li{plt.gca()}.\n\\end{info}\n\n\\begin{problem} % Subplots of sine functions.\nWrite a function that plots the functions $\\sin(x)$, $\\sin(2x)$, $2\\sin(x)$, and $2\\sin(2x)$ on the domain $[0, 2\\pi]$, each in a separate subplot of a single figure.\n\\begin{enumerate}\n \\item Arrange the plots in a $2\\times 2$ grid of subplots.\n \\item Set the limits of each subplot to $[0, 2\\pi]\\times[-2,2]$.\n \\\\(Hint: Consider using \\li{plt.axis([xmin, xmax, ymin, ymax])} instead of \\li{plt.xlim()} and \\li{plt.ylim()} to set all boundaries simultaneously.)\n \\item Use \\li{plt.title()} or \\li{ax.set_title()} to give each subplot an appropriate title.\n \\item Use \\li{plt.suptitle()} or \\li{fig.suptitle()} to give the overall figure a title.\n \\item Use the following colors and line styles.\n \\begin{align*}\\begin{array}{lcl}\n \\sin(x)\\text{: green solid line.} && \\sin(2x)\\text{: red dashed line.}\\\\ \\\\\n 2\\sin(x)\\text{: blue dashed line.} && 2\\sin(2x)\\text{: magenta dotted line.}\n \\end{array}\\end{align*}\n\\end{enumerate}\n\\end{problem}\n\n\\begin{warn}\nBe careful not to mix up the following functions.\n\\begin{enumerate}\n \\item \\li{plt.axes()} creates a new place to draw on the figure, while \\li{plt.axis()} (or \\li{ax.axis()}) sets properties of the $x$- and $y$-axis in the current axes, such as the $x$ and $y$ limits.\n \\item \\li{plt.subplot()} (singular) returns a single subplot belonging to the current figure, while \\li{plt.subplots()} (plural) creates a new figure and adds a collection of subplots to it.\n\\end{enumerate}\n% The \\li{subplots()} function is especially useful for figures with many subplots.\n% \\begin{lstlisting}\n% # The subplot axes are organized in an array of the given shape.\n% >>> fig, ax = plt.sublplots(2,3)\n% >>> ax.shape\n% (2, 3)\n% >>> ax[1,1].plot([1,2,3],[4,5,6])\n% # ...\n% \\end{lstlisting}\n\\end{warn}\n\n\\section*{Other Kinds of Plots} % =============================================\n\nLine plots are not always the most illuminating choice of graph to describe a set of data.\nMatplotlib provides several other easy ways to visualize data.\n\n\\begin{itemize}\n\\item A \\emph{scatter plot} plots two 1-dimensional arrays against each other without drawing lines between the points.\nScatter plots are particularly useful for data that is not correlated or ordered.\n\nTo create a scatter plot, use \\li{plt.plot()} and specify a point marker (such as \\li{'o'} or \\li{'*'}) for the line style, or use \\li{plt.scatter()} (or \\li{ax.scatter()}).\nBeware that \\li{plt.scatter()} has slightly different arguments and syntax than \\li{plt.plot()}.\n\n\\item A \\emph{histogram} groups entries of a 1-dimensional data set into a given number of intervals, called \\emph{bins}.\nEach bin has a bar whose height indicates the number of values that fall in the range of the bin.\n% The more bins, the greater the detail, but having too many bins can also destroy the picture by creating interval gaps between values.\nHistograms are best for displaying distributions, relating data values to frequency.\n\nTo create a histogram, use \\li{plt.hist()} (or \\li{ax.hist()}).\nUse the argument \\li{bins} to specify the edges of the bins, or to choose a number of bins.\nThe \\li{<>} argument specifies the outer limits of the first and last bins.\n\\end{itemize}\n\n\\begin{lstlisting}\n# Get 500 random samples from two normal distributions.\n>>> x = np.random.normal(scale=1.5, size=500)\n>>> y = np.random.normal(scale=0.5, size=500)\n\n# Draw a scatter plot of x against y, using transparent circle markers.\n>>> ax1 = plt.subplot(121)\n>>> ax1.plot(x, y, 'o', markersize=5, alpha=.5)\n\n# Draw a histogram to display the distribution of the data in x.\n>>> ax2 = plt.subplot(122)\n>>> ax2.hist(x, bins=np.arange(-4.5, 5.5)) # Or, equivalently,\n# ax2.hist(x, bins=9, range=[-4.5, 4.5])\n\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{framed}\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/scatterplot.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/histogram.pdf}\n\\end{subfigure}\n\\end{framed}\n\\end{figure}\n\n% On the histogram, specifying 9 bins in the range $[-4.5, 4.5]$ creates a bin centered over each integer from $-4$ to $4$.\n\n\\begin{problem} % FARS data visualization.\nThe Fatality Analysis Reporting System (FARS) is a nationwide census that provides yearly data regarding fatal injuries suffered in motor vehicle traffic crashes.%\n\\footnote{See \\url{http://www.nhtsa.gov/FARS}.}\nThe array contained in \\texttt{FARS.npy} is a small subset of the FARS database from 2010--2014.\nEach of the 148,206 rows in the array represents a different car crash; the columns represent the hour (in military time, as an integer), the longitude, and the latitude, in that order.\n\nWrite a function to visualize the data in \\texttt{FARS.npy}.\nUse \\li{np.load()} to load the data, then create a single figure with two subplots:\n%\n\\begin{enumerate}\n\\item A scatter plot of longitudes against latitudes.\nBecause of the large number of data points, use black pixel markers (use \\li{\"k,\"} as the third argument to \\li{plt.plot()}).\nLabel both axes using \\li{plt.xlabel()} and \\li{plt.ylabel()} (or \\li{ax.set_xlabel()} and \\li{ax.set_ylabel()}).\n\\\\\n(Hint: Use \\li{plt.axis(\"equal\")} or \\li{ax.set_aspect(\"equal\")} so that the $x$- and $y$-axis are scaled the same way.\n\n\\item A histogram of the hours of the day, with one bin per hour.\nSet the limits of the $x$-axis appropriately.\nLabel the $x$-axis.\nYou should be able to clearly see which hours of the day experience more traffic.\n\\end{enumerate}\n\\end{problem}\n\nMatplotlib also has tools for creating other kinds of plots for visualizing 1-dimensional data, including bar plots and box plots.\nSee the Matplotlib Appendix for examples and syntax.\n\n\\subsection*{Visualizing 3-D Surfaces} % --------------------------------------\n\nLine plots, histograms, and scatter plots are good for visualizing $1$- and $2$-dimensional data, including the domain and range of a function $f:\\mathbb{R}\\rightarrow\\mathbb{R}$.\nHowever, visualizing $3$-dimensional data or a function $g:\\mathbb{R}^2\\rightarrow\\mathbb{R}$ (two inputs, one output) requires a different kind of plot.\nThe process is similar to creating a line plot but requires slightly more setup: first construct an appropriate domain, then calculate the image of the function on that domain.\n\nNumPy's \\li{np.meshgrid()} function is the standard tool for creating a 2-dimensional domain in the Cartesian plane.\nGiven two 1-dimensional coordinate arrays, \\li{np.meshgrid()} creates two corresponding coordinate matrices.\nSee Figure \\ref{fig:meshgrid}.\n\n\\begin{figure}[H] % np.meshgrid() visual demonstration.\n\\begin{tikzpicture}[>=stealth', shorten <= .1cm,shorten >=.1cm, dot/.style=\n {circle,fill=black,minimum size=3pt,inner sep=0pt, outer sep=-1pt} ]\n\n\\foreach \\x/\\y in {0/0, 0/2, 0/4, 2/0, 2/2, 2/4, 4/0, 4/2, 4/4}\n \\node[draw, dot]at(\\x,\\y){};\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*2-.5, \\y*2+.3){(\\x,\\y)};\n\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*.75+7, \\y*.75+.1){\\y};\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*.75+7, \\y*-.75+3.9){\\x};\n\n\\draw[-, thick](6.7,-.25)--(6.7,1.95);\n\\draw[-, thick](8.8,-.25)--(8.8,1.95);\n\\draw[-, thick](6.7,2.05)--(6.7,4.25);\n\\draw[-, thick](8.8,2.05)--(8.8,4.25);\n\\draw[-, thick](8.8,4.14)--(8.7,4.14);\n\\draw[-, thick](8.8,2.16)--(8.7,2.16);\n\\draw[-, thick](6.7,4.14)--(6.8,4.14);\n\\draw[-, thick](6.7,2.16)--(6.8,2.16);\n\\draw[-, thick](8.8,1.84)--(8.7,1.84);\n\\draw[-, thick](8.8,-.135)--(8.7,-.135);\n\\draw[-, thick](6.8,1.84)--(6.7,1.84);\n\\draw[-, thick](6.8,-.135)--(6.7,-.135);\n\n\\node[draw=none](X)at(6.3,.9){\\texttt{Y}=};\n\\node[draw=none](y)at(6.3,3.15){\\texttt{X}=};\n\n\\node[draw=none](point1)at(-.3, -.6){\\texttt{x}=\\big[0,};\n\\node[draw=none, node distance=2.35cm](point2)\n [right of=point1]{1,};\n\\node[draw=none, node distance=2cm](point3)\n [right of=point2]{2\\big]};\n\\node[draw=none, rotate=270](point4)at(4.6,4.25)\n {\\texttt{y}=\\big[2,};\n\\node[draw=none, rotate=270, node distance=2.35cm](point5)\n [right of=point4]{1,};\n\\node[draw=none, rotate=270, node distance=2cm](point6)\n [right of=point5]{0\\big]};\n\\end{tikzpicture}\n\\caption{\\li{np.meshgrid(x, y)}, returns the arrays \\li{X} and \\li{Y}.\nThe returned arrays give the $x$- and $y$-coordinates of the points in the grid formed by \\li{x} and \\li{y}.\nSpecifically, the arrays \\li{X} and \\li{Y} satisfy \\li{(X[i,j], Y[i,j]) = (x[i],y[j])}.}\n\\label{fig:meshgrid}\n\\end{figure}\n\n\\begin{lstlisting}\n>>> x, y = [0, 1, 2], [3, 4, 5] # A rough domain over [0,2]x[3,5].\n>>> X, Y = np.meshgrid(x, y) # Combine the 1-D data into 2-D data.\n>>> for xrow, yrow in zip(X,Y):\n... print(xrow, yrow, sep='\\t')\n...\n[0 1 2] [3 3 3]\n[0 1 2] [4 4 4]\n[0 1 2] [5 5 5]\n\\end{lstlisting}\n\nWith a 2-dimensional domain, $g(x,y)$ is usually visualized with two kinds of plots.\n\n\\begin{itemize}\n\\item A \\emph{heat map} assigns a color to each point in the domain, producing a 2-dimensional colored picture describing a 3-dimensional shape.\nDarker colors typically correspond to lower values while lighter colors typically correspond to higher values.\n\nUse \\li{plt.pcolormesh()} to create a heat map.\n\n\\item A \\emph{contour map} draws several \\emph{level curves} of $g$ on the $2$-dimensional domain.\nA level curve corresponding to the constant $c$ is the collection of points $\\left\\{(x,y)\\mid c = g(x,y)\\right\\}$.\nColoring the space between the level curves produces a discretized version of a heat map.\nIncluding more and more level curves makes a filled contour plot look more and more like the complete, blended heat map.\n\nUse \\li{plt.contour()} to create a contour plot and \\li{plt.contourf()} to create a filled contour plot.\nSpecify either the number of level curves to draw, or a list of constants corresponding to specific level curves.\n\\end{itemize}\n\nThese functions each receive the keyword argument \\li{cmap} to specify a color scheme (some of the better schemes are \\li{\"viridis\"}, \\li{\"magma\"}, and \\li{\"coolwarm\"}).\nFor the list of all Matplotlib color schemes, see \\url{http://matplotlib.org/examples/color/colormaps_reference.html}.\n\nFinally, \\li{plt.colorbar()} draws the color scale beside the plot to indicate how the colors relate to the values of the function.\n\n\\begin{lstlisting}\n# Create a 2-D domain with np.meshgrid().\n>>> x = np.linspace(-np.pi, np.pi, 100)\n>>> y = x.copy()\n>>> X, Y = np.meshgrid(x, y)\n>>> Z = np.sin(X) * np.sin(Y) # Calculate g(x,y) = sin(x)sin(y).\n\n# Plot the heat map of f over the 2-D domain.\n>>> plt.subplot(131)\n>>> plt.pcolormesh(X, Y, Z, cmap=\"viridis\")\n>>> plt.colorbar()\n>>> plt.xlim(-np.pi, np.pi)\n>>> plt.ylim(-np.pi, np.pi)\n\n# Plot a contour map of f with 10 level curves.\n>>> plt.subplot(132)\n>>> plt.contour(X, Y, Z, 10, cmap=\"coolwarm\")\n>>> plt.colorbar()\n\n# Plot a filled contour map, specifying the level curves.\n>>> plt.subplot(133)\n>>> plt.contourf(X, Y, Z, [-1, -.8, -.5, 0, .5, .8, 1], cmap=\"magma\")\n>>> plt.colorbar()\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H] % heat map and contour plots.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{framed}\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/heatmap.png}\n\\end{subfigure}%\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/contour.pdf}\n\\end{subfigure}%\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/contourf.pdf}\n\\end{subfigure}\n\\end{framed}\n\\end{figure}\n\n\\begin{problem} % Heat map / contour plot of a function f:R2->R.\n\\label{prob:heatmap}\nWrite a function to plot $g(x,y) = \\frac{\\sin(x)\\sin(y)}{xy}$ on the domain $[-2\\pi,2\\pi] \\times [-2\\pi,2\\pi]$.\n\n\\begin{enumerate}\n\\item Create 2 subplots: one with a heat map of $g$, and one with a contour map of $g$.\nChoose an appropriate number of level curves, or specify the curves yourself.\n\\item Set the limits of each subplot to $[-2\\pi,2\\pi] \\times [-2\\pi,2\\pi]$.\n\\item Choose a non-default color scheme.\n\\item Include the color scale bar for each subplot.\n\\end{enumerate}\n\\end{problem}\n\n\\begin{comment}\n\\begin{info} % Note about plt.imshow().\nBlack-and-white pictures are usually stored as a $2$-dimensional array and colord pictures are stored as a $3$-dimensional array (a stack of 2-dimensional arrays, one for each RGB value).\nThis kind of data does not require a domain, and is easily visualized with \\li{plt.imshow()}.\n\\end{info}\n\\end{comment}\n\n\\newpage\n\n\\section*{Additional Material} % ==============================================\n\n\\subsection*{Further Reading and Tutorials} % ---------------------------------\n\nPlotting takes some getting used to.\nSee the following materials for more examples.\n\\begin{itemize}\n \\item \\url{https://www.labri.fr/perso/nrougier/teaching/matplotlib/}.\n \\item \\url{https://matplotlib.org/users/pyplot_tutorial.html}.\n \\item \\url{http://www.scipy-lectures.org/intro/matplotlib/matplotlib.html}.\n \\item The Matplotlib Appendix in this manual.\n\\end{itemize}\n\n\\subsection*{3-D Plotting} % --------------------------------------------------\n\nMatplotlib can also be used to plot 3-dimensional surfaces.\nThe following code produces the surface corresponding to $g(x,y) = \\sin(x)\\sin(y)$.\n\n\\begin{lstlisting}\n# Create the domain and calculate the range like usual.\n>>> x = np.linspace(-np.pi, np.pi, 200)\n>>> y = np.copy(x)\n>>> X, Y = np.meshgrid(x, y)\n>>> Z = np.sin(X) * np.sin(Y)\n\n# Draw the corresponding 3-D plot using some extra tools.\n>>> from mpl_toolkits.mplot3d import Axes3D\n>>> fig = plt.figure()\n>>> ax = fig.add_subplot(1,1,1, projection='3d')\n>>> ax.plot_surface(X, Y, Z)\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n \\includegraphics[width=.7\\textwidth]{figures/surface_plot.pdf}\n\\end{figure}\n\n\\subsection*{Animations} % ----------------------------------------------------\n\nLines and other graphs can be altered dynamically to produce animations.\nFollow these steps to create a Matplotlib animation:\n%\n\\begin{enumerate}\n \\item Calculate all data that is needed for the animation.\n \\item Define a figure explicitly with \\li{plt.figure()} and set its window boundaries.\n \\item Draw empty objects that can be altered dynamically.\n \\item Define a function to update the drawing objects.\n \\item Use \\li{matplotlib.animation.FuncAnimation()}.\n\\end{enumerate}\n\nThe submodule \\li{matplotlib.animation} contains the tools for putting together and managing animations.\nThe function \\li{matplotlib.animation.FuncAnimation()} accepts the figure to animate, the function that updates the figure, the number of frames to show before repeating, and how fast to run the animation (lower numbers mean faster animations).\n\n\\begin{lstlisting}\nfrom matplotlib.animation import FuncAnimation\n\ndef sine_animation():\n # Calculate the data to be animated.\n x = np.linspace(0, 2*np.pi, 200)[:-1]\n y = np.sin(x)\n\n # Create a figure and set the window boundaries of the axes.\n fig = plt.figure()\n plt.xlim(0, 2*np.pi)\n plt.ylim(-1.2, 1.2)\n\n # Draw an empty line. The comma after 'drawing' is crucial.\n drawing, = plt.plot([],[])\n\n # Define a function that updates the line data.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n return drawing, # Note the comma!\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10)\n plt.show()\n\\end{lstlisting}\n\nTry using the following function in place of \\li{update()}.\nCan you explain why this animation is different from the original?\n\n\\begin{lstlisting}\ndef wave(index):\n drawing.set_data(x, np.roll(y, index))\n return drawing,\n\\end{lstlisting}\n\n% \\begin{comment} % Too much.\nTo animate multiple objects at once, define the objects separately and make sure the update function returns both objects.\n\n\\begin{lstlisting}\ndef sine_cosine_animation():\n x = np.linspace(0, 2*np.pi, 200)[:-1]\n y1, y2 = np.sin(x), np.cos(x)\n\n fig = plt.figure()\n plt.xlim(0, 2*np.pi)\n plt.ylim(-1.2, 1.2)\n\n sin_drawing, = plt.plot([],[])\n cos_drawing, = plt.plot([],[])\n\n def update(index):\n sin_drawing.set_data(x[:index], y1[:index])\n cos_drawing.set_data(x[:index], y2[:index])\n return sin_drawing, cos_drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10)\n plt.show()\n\\end{lstlisting}\n% \\end{comment}\n\n\\begin{comment} % Too much.\nAnimations are very useful for describing parametrized curves, as the ``speed'' of the curve is displayed.\nThe code below animates the rose curve, parametrized by the angle $\\theta \\in [0, 2\\pi]$, given by the following equations.\n%\n\\[\\begin{array}{ccc}\nx(\\theta) = \\cos(\\theta)\\cos(6\\theta), && y(\\theta) = \\sin(\\theta)\\cos(6\\theta)\n\\end{array}\\]\n\n\\begin{lstlisting}\ndef rose_animation():\n # Calculate the parametrized data.\n theta = np.linspace(0, 2*np.pi, 200)\n x = np.cos(theta)*np.cos(6*theta)\n y = np.sin(theta)*np.cos(6*theta)\n\n fig = plt.figure()\n plt.xlim(-1.2, 1.2)\n plt.ylim(-1.2, 1.2)\n plt.gca().set_aspect(\"equal\") # Make the figure exactly square.\n\n drawing, = plt.plot([],[])\n\n # Define a function that updates the line data.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n return drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10, repeat=False)\n plt.show() # repeat=False freezes the animation at the end.\n\\end{lstlisting}\n\\end{comment}\n\nAnimations can also be 3-dimensional.\nThe only major difference is an extra operation to set the 3-dimensional component of the drawn object.\nThe code below animates the space curve parametrized by the following equations:\n%\n\\[\\begin{array}{ccccc}\nx(\\theta) = \\cos(\\theta)\\cos(6\\theta), &&\ny(\\theta) = \\sin(\\theta)\\cos(6\\theta), &&\nz(\\theta) = \\frac{\\theta}{10}\n\\end{array}\\]\n\n\\begin{lstlisting}\ndef rose_animation_3D():\n theta = np.linspace(0, 2*np.pi, 200)\n x = np.cos(theta) * np.cos(6*theta)\n y = np.sin(theta) * np.cos(6*theta)\n z = theta / 10\n\n fig = plt.figure()\n ax = fig.gca(projection='3d') # Make the figure 3-D.\n ax.set_xlim3d(-1.2, 1.2) # Use ax instead of plt.\n ax.set_ylim3d(-1.2, 1.2)\n ax.set_aspect(\"equal\")\n\n drawing, = ax.plot([],[],[]) # Provide 3 empty lists.\n\n # Update the first 2 dimensions like usual, then update the 3-D component.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n drawing.set_3d_properties(z[:index])\n return drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10, repeat=False)\n plt.show()\n\\end{lstlisting}\n\n% See \\url{https://matplotlib.org/2.0.0/examples/animation/index.html} for more examples.\n\n\\begin{comment} % TODO: An ORIGINAL example of using widgets\n\\subsection*{Interactive Plots} % ---------------------------------------------\n\nMatplotlib plots can be made interactive by adding \\emph{widgets}.\nConsider the following example, TAKEN FROM THE MATPLOTLIB DOCS BASICALLY AHHH\n\n\\begin{lstlisting}\n>>> from matplotlib import widgets as wg\n\n>>> ax = plt.subplot(111)\n>>> plt.subplots_adjust(bottom=.25) # Make some space for a slider bar.\n>>> t = np.arange(0., 1., .001)\n>>> a0 = 5.\n>>> f0 = 3.\n>>> s = a0 * np.sin(2 * np.pi * f0 * t)\n>>> l = plt.plot(t, s)[0]\n>>> plt.axis([0, 1, -10, 10])\n>>> axfreq = plt.axes([.25, .05, .65, .03])\n>>> axamp = plt.axes([.25, .1, .65, .03])\n\n# Make some slider bars.\n>>> sfreq = wg.Slider(axfreq, 'Freq', .1, 30., valinit=f0)\n>>> samp = wg.Slider(axamp, 'Amp', .1, 10., valinit=a0)\n>>> def update(val): # Function for updating the plot.\n... amp = samp.val # Read from one slider.\n... freq = sfreq.val # Read from the other slider.\n... l.set_ydata(amp * np.sin(2 * np.pi * freq * t))\n... plt.draw() # Refresh the plot.\n>>> sfreq.on_changed(update) # Connect the sliders to update().\n>>> samp.on_changed(update)\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n\\includegraphics[width=.7\\textwidth]{figures/interactive_plot.pdf}\n\\end{figure}\n\\end{comment}\n\n% =============================================================================\n% =============================================================================\n% Stuff to move ===============================================================\n% =============================================================================\n% =============================================================================\n\n\\begin{comment}\n\\begin{info} % IPython Notebook inline plotting (move to notebook intro)\nIf you are executing these Matplotlib commands in an IPython shell, executing the \\li{plt.show()} method will open a new window with the plot.\nIf you are using IPython Notebook, you have the option to display the plots within your notebook.\nYou may opt into this feature by running \\li{\\%matplotlib inline} or \\li{\\%matplotlib notebook} in your IPython Notebook.\nThe \\li{inline} option shows the plot, whereas the \\li{notebook} option shows the plot and provides controls to interact with the plot.\nAdditionally, when using this option, the plot is displayed after running the \\li{plt.plot()} command; the \\li{plt.show()} command is not necessary.\n\\end{info}\n\\end{comment}\n", "meta": {"hexsha": "f0f1275916cd1db2340494b7cde1964f3b729a80", "size": 37252, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "acme-material/Labs/PythonEssentials/MatplotlibIntro/MatplotlibIntro.tex", "max_stars_repo_name": "DM561/dm561.github.io", "max_stars_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-13T13:22:41.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-13T13:22:41.000Z", "max_issues_repo_path": "acme-material/Labs/PythonEssentials/MatplotlibIntro/MatplotlibIntro.tex", "max_issues_repo_name": "DM561/dm561.github.io", "max_issues_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-10-18T19:57:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-31T19:00:36.000Z", "max_forks_repo_path": "acme-material/Labs/PythonEssentials/MatplotlibIntro/MatplotlibIntro.tex", "max_forks_repo_name": "DM561/dm561.github.io", "max_forks_repo_head_hexsha": "216e8f41007f4f4fbd174c529f543b20bb477702", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.2358276644, "max_line_length": 269, "alphanum_fraction": 0.6725008053, "num_tokens": 10802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110425624792, "lm_q2_score": 0.947381044980928, "lm_q1q2_score": 0.8448848774283725}} {"text": "\\subsection{Time step selection}\nThe easier way to determine $\\Delta t$ is to select it as a constant for all the simulation iterations.\nFor visualization concerns we will sometimes use a constant $\\Delta t$ but, for simulation precision interests, it is better to compute a new time step for each iterations depending on the distance between the nearest bodies.\nThe following equation describes the variable $\\Delta t$ calculation:\n\\begin{equation}\n\\label{eq:dt1}\n\t\\|\\vec{v_i}(t) . \\Delta t + \\frac{\\vec{a_i}(t)}{2} . \\Delta t^2 \\| \\leq 0.1 \\times ||\\vec{r_{ij}}||,\n\\end{equation}\nwith $j$ the nearest body to the body $i$.\nFor each body $i$, a time step is calculated and the smallest one is chosen.\nEq.~\\ref{eq:dt1} traduces that the distance between $i(t)$ and $i(t + \\Delta t)$ must be below 10\\% of the $||\\vec{r_{ij}}||$ distance.\nThis equation assures that two masses cannot be closest than 20\\% between $t$ time and $t + \\Delta t$ time.\nHowever, Eq.~\\ref{eq:dt1} is not directly usable: this is a $4^{th}$ degree polynomial equation in $\\Delta t$.\nIt's why we will use the triangle inequality witch allows us to determine a new condition:\n\\begin{equation}\n\\label{eq:dt2}\n\t\\|\\vec{v_i}(t)\\| . \\Delta t + \\frac{\\|\\vec{a_i}(t)\\|}{2} . \\Delta t^2 \\leq 0.1 \\times ||\\vec{r_{ij}}||.\n\\end{equation}\nEq.~\\ref{eq:dt2} is a $2^{nd}$ degree equation: this is more reasonable in term of computational time.\n\n\\subsection{Time integration}\n\\sout{The integrator used to update the positions and velocities is a leapfrog-Verlet integrator (Verlet 1967) because it is applicable to this problem and is computationally efficient (it has a high ratio of accuracy to computational cost).}\n\nBody $i$ velocity characteristic at the $t + \\Delta t$ time depends on the velocity and the acceleration at the $t$ time:\n\\begin{equation}\n\\label{eq:velocity}\n\t\\vec{v_i}(t + \\Delta t) = \\vec{v_{i}}(t) + \\vec{a_i}(t) . \\Delta t.\n\\end{equation}\nAt the end, body $i$ position $q_i$ at the $t + \\Delta t$ time depends on the position, the velocity and the acceleration at the $t$ time:\n\\begin{equation}\n\\label{eq:position}\n\tq_i(t + \\Delta t) = q_{i}(t) + \\vec{v_{i}}(t) . \\Delta t + \\frac{\\vec{a_i}(t) . \\Delta t^2}{2}.\n\\end{equation}\nThanks to Eq.~\\ref{eq:acceleration}, \\ref{eq:velocity} and \\ref{eq:position}, it is now possible to compute the new position and the new velocity for all bodies at the $t + \\Delta t$ time.\n", "meta": {"hexsha": "d887c2bcf4506b65ba1359db953ba42a71422484", "size": 2399, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/murb/sections/time.tex", "max_stars_repo_name": "MisterFruits/MUrB", "max_stars_repo_head_hexsha": "b855332f3eb0fd4a8baa203c28dc0e8e5ce50538", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2017-07-08T16:45:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-23T08:45:01.000Z", "max_issues_repo_path": "doc/murb/sections/time.tex", "max_issues_repo_name": "MisterFruits/MUrB", "max_issues_repo_head_hexsha": "b855332f3eb0fd4a8baa203c28dc0e8e5ce50538", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-09-08T14:35:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-10T07:53:18.000Z", "max_forks_repo_path": "doc/murb/sections/time.tex", "max_forks_repo_name": "MisterFruits/MUrB", "max_forks_repo_head_hexsha": "b855332f3eb0fd4a8baa203c28dc0e8e5ce50538", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-09T07:08:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-09T07:08:08.000Z", "avg_line_length": 68.5428571429, "max_line_length": 242, "alphanum_fraction": 0.7094622759, "num_tokens": 741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768541530197, "lm_q2_score": 0.8947894717137996, "lm_q1q2_score": 0.8448395085319778}} {"text": "\\subsubsection{Complex Eigenvalues}\r\n\\begin{theorem}\r\n\tIf an $n \\times n$ matrix $A$ is not defective, then for each pair of complex eigenvalues $\\alpha \\pm \\beta i$ with corresponding eigenvectors $\\vec{a} \\pm i\\vec{b}$, the corresponding fundamental solutions are $e^{\\alpha t}\\left(\\cos{(\\beta t)}\\vec{a}-\\sin{(\\beta t)\\vec{b}}\\right)$ and $e^{\\alpha t}\\left(\\sin{(\\beta t)}\\vec{a}+\\cos{(\\beta t)\\vec{b}}\\right)$.\r\n\\end{theorem}\r\n\r\n\\begin{example}\r\n\tFind the general solution to the system\r\n\t\\begin{equation*}\r\n\t\t\\vec{x}' = \\begin{bmatrix}\r\n\t\t\t2 & 3 \\\\\r\n\t\t\t-3 & 2\r\n\t\t\\end{bmatrix} \\vec{x}.\r\n\t\\end{equation*}\r\n\\end{example}\r\n\\noindent\r\nFinding the eigenvalues by finding the roots of the characteristic polynomial of $A$,\r\n\\begin{equation*}\r\n\tp(\\lambda) = \\det{(A - \\lambda I)} = (2-\\lambda)^2 + 9 \\implies \\lambda = 2 \\pm 3i.\r\n\\end{equation*}\r\nFinding the eigenvectors for $\\lambda = 2 + 3i$, remembering that once we have the two eigenvectors, we don't need to find them for the conjugate,\r\n\\begin{equation*}\r\n\t(A - (2+3i)I)\\vec{v} = \\vec{0} \\implies \\vec{v} = C_1\\begin{bmatrix}\r\n\t\t0 \\\\\r\n\t\t1\r\n\t\\end{bmatrix} + C_2i\\begin{bmatrix}\r\n\t\t-1 \\\\\r\n\t\t0\r\n\t\\end{bmatrix}.\r\n\\end{equation*}\r\nSo, our solution is\r\n\\begin{equation*}\r\n\t\\vec{x} = C_1e^{2t}\\left(\\cos{(3t)}\\begin{bmatrix}\r\n\t\t0 \\\\\r\n\t\t1\r\n\t\\end{bmatrix}-\\sin{(3t)}\\begin{bmatrix}\r\n\t\t-1 \\\\\r\n\t\t0\r\n\t\\end{bmatrix}\\right) + C_2e^{2t}\\left(\\sin{(3t)}\\begin{bmatrix}\r\n\t\t0 \\\\\r\n\t\t1\r\n\t\\end{bmatrix}+\\cos{(3t)}\\begin{bmatrix}\r\n\t\t-1 \\\\\r\n\t\t0\r\n\t\\end{bmatrix}\\right).\r\n\\end{equation*}\r\nWe can rewrite this a little more elegantly as\r\n\\begin{equation*}\r\n\t\\vec{x} = \\begin{bmatrix}\r\n\t\t\\sin{(3t)} & - \\cos{(3t)} \\\\\r\n\t\t\\sin{(3t)} & \\cos{(3t)}\r\n\t\\end{bmatrix} \\begin{bmatrix}\r\n\t\tC_1 \\\\\r\n\t\tC_2\r\n\t\\end{bmatrix} e^{2t}.\r\n\\end{equation*}", "meta": {"hexsha": "df8535b79dcccccb4768a1275ddd90a6664e926a", "size": 1764, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "diffEq/linearSystems/homogeneousSystems/complexEigenvalues.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "diffEq/linearSystems/homogeneousSystems/complexEigenvalues.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "diffEq/linearSystems/homogeneousSystems/complexEigenvalues.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 32.0727272727, "max_line_length": 363, "alphanum_fraction": 0.6218820862, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172688214137, "lm_q2_score": 0.8902942363098472, "lm_q1q2_score": 0.8448155751665865}} {"text": "\\begin{solution}\nIn this problem we are asked approximate the first derivative of the function\n\\begin{align*}\nf(x)=\\frac{1+2x^2\\cos{x}}{x^{2.4}},\n\\end{align*}\nat a given point $x_0=33.3$. We can calculate the derivative analytically,\n\\begin{align*}\nf'(x)=\\frac{2x^2(2\\cos{x}-x\\sin{x})-2.4(1+2x^2\\cos{x})}{x^{3.4}},\n\\end{align*}\nand its value at $x_0$ is $f'(x_0)=-0.466342049195729$ using double precision in \\textsc{MATLAB}. We are asked to plot, in logarithmic scale, the truncation error of three different approximations versus the step $h$. The approximations to use are\n\\begin{itemize}\n\\item First order forward diffrences:\n\\begin{align*}\nf'_i=\\frac{f_{i+1}-f_i}{h}+\\mathcal{O}(h).\n\\end{align*}\n\\item Second order central diffrences:\n\\begin{align*}\nf'_i=\\frac{f_{i+1}-f_{i-1}}{2h}+\\mathcal{O}(h^2).\n\\end{align*}\n\\item Sixth order central differences:\n\\begin{align*}\nf'_i=\\frac{-f_{i-3}+9f_{i-2}-45f_{i-1}+45f_{i+1}-9f_{i+2}+f_{i+3}}{60h}+\\mathcal{O}(h^6).\n\\end{align*}\n\\end{itemize}\nOnce the value of each approximation is obtained, we can compute the error for every value of the step $h$ and show it in the next figure.\n\\begin{figure}[H]\n\\centering %%% not \\center\n\\hspace{-0.56in}\n\\includegraphics[scale=0.5]{IMAGES/problem2_1_edit.eps}\\caption{Error of the different approximations and reference lines.}\n\\end{figure}\n\nThe fact that the error describes a straight line of slope $m$ in logarithmic scale proves that that approximation is of order $m$ (since $\\log{(kh^m)}=\\log{k}+m\\log h$, a straight line of slope $m$). In our case, it is clear in the figure that the approximations are, from top to bottom, indeed of order one, two and six, respectively. However, this linear dependence is broken in two areas of the figure. \n\nFirst, when $h$ is sufficiently small, the \\textit{rounding-error} is dominant and we see it as a cloud of points that seem parallel to the line of slope negative one. This is due to the fact that the rounding error is of the order of $\\frac{\\epsilon}{h}$, where $\\epsilon$ is the well known machine epsilon. An error of that order is shown in logarithmic scale as a straight line of slope negative one (since $\\log{(\\frac{\\epsilon}{h})}=\\log{\\epsilon}-\\log{h}$ and $\\epsilon$ is constant). The point where the rounding error becomes dominant depends, of course, of the order of approximation. The higher the order, as we make $h$ small, the powers of $h$ are even smaller and when they get of the order of $\\epsilon$ the computer cannot differ well enough between numbers. \n\nOn the other hand, when $h$ is large, the terms of the error that are not the leading error term become more and more important as $h$ increases, reaching the point of not being neglectable. We can reach the point where the leading error term is not so anymore since we need $h$ to be small in order to assume that the remaining terms of the series are considerably smaller. We can see that effect in the top right corner of the figure.\n\n\\subsection*{Matlab code for the problem}\n\\section*{HOMEWORK 1 - FRANCISCO CASTILLO}\n\n\n\\subsection*{Contents}\n\n\\begin{itemize}\n\\setlength{\\itemsep}{-1ex}\n \\item Problem 2\n\\end{itemize}\n\n\n\\subsection*{Problem 2}\n\n\\begin{verbatim}\nformat long;clear all;close all;clc\nx_0=33.3;\nf = @(x) (1+2*x^2*cos(x))/(x^(2.4));\nfp = @(x) (2*x^2*(2*cos(x)-x*sin(x))-2.4*(1+2*x^2*cos(x)))/(x^3.4);\nfor k = -3:1:25\n H(k+4) = 2^(-k);\nend\nfor k = 1:length(H)\n h = H(k);\n df1(k) = (f(x_0+h)-f(x_0))/h;\n df2(k) = (f(x_0+h)-f(x_0-h))/(2*h);\n df6(k) = (45*(f(x_0+h)-f(x_0-h))-9*(f(x_0+2*h)-f(x_0-2*h))...\n +(f(x_0+3*h)-f(x_0-3*h)))/(60*h);\nend\nlinewidth=2;\ndarkgreen=[0 0.6 0];\nfigure('units','normalized','outerposition',[0 0 1 1])\nloglog(H,abs(df1-fp(x_0)),'*',H,abs(df2-fp(x_0)),'*')\nhold on\nloglog(H,abs(df6-fp(x_0)),'*','Color',darkgreen)\nloglog(H,H/2,'b--',H,H.^(2)/6,'r--','linewidth',linewidth)\nloglog(H,H.^(6)/140,'--','Color',darkgreen,'linewidth',linewidth)\nloglog(H,eps./H,'k:','linewidth',linewidth)\nset(gca,'fontsize',14)\naxis([1e-8 1e1 1e-20 1e5])\ngrid on\nxlabel('$h$ (log scale)','fontsize',20,'interpreter','latex')\nylabel('Error (log scale)','fontsize',20,'interpreter','latex')\nsaveas(gcf,'IMAGES/problem2_1','epsc')\nsaveas(gcf,'IMAGES/problem2_1','fig')\n\\end{verbatim}\n\\end{solution}", "meta": {"hexsha": "2df83aee70775ab8744978cc7cf7db3af1d00a8b", "size": 4257, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Year_1/CFD/Homework 1/problem2.tex", "max_stars_repo_name": "fjcasti1/Courses", "max_stars_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Year_1/CFD/Homework 1/problem2.tex", "max_issues_repo_name": "fjcasti1/Courses", "max_issues_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Year_1/CFD/Homework 1/problem2.tex", "max_forks_repo_name": "fjcasti1/Courses", "max_forks_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.6785714286, "max_line_length": 774, "alphanum_fraction": 0.6983791402, "num_tokens": 1418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088045171237, "lm_q2_score": 0.9099070072595894, "lm_q1q2_score": 0.8447656768316292}} {"text": "\\chapter{Dual Spaces}\nConsider a vector space $V$ over a field $\\mathbb{F}$ with basis $\\{\\vec{e}_\\mu\\}$.\nThe \\emph{Dual Space} of $V$, denoted $V^*$, is the set of all linear maps from $V$ to $\\mathbb{F}$:\n\\begin{align*}\n V^* = \\{\\phi : \\phi(\\vec{v}) \\in \\mathbb{F}, \\phi \\text{ is linear}\\}.\n\\end{align*}\nElements of $V^*$ are known as \\emph{covectors}. Note that if we've created $V$, we don't need to do anything to create $V^*$; it is automatically created by $V$.\n\nThis dual space is itself a vector space, since we can give it a concept of addition and scalar multiplication, and the zero covector.\n\\begin{itemize}\n \\item Addition: Consider covectors $\\Lambda$ and $Z$ of the dual space of $V$ (so they are linear maps from $V$ to $\\mathbb{F}$), and a vector $\\vec{v} \\in V$. We can say that $\\langle \\Lambda + Z, \\vec{v} \\rangle = \\langle \\Lambda,\\vec{v} \\rangle + \\langle Z, \\vec{v} \\rangle$.\n \\item Scalar multiplication: Again with a covector (linear map) $\\Lambda$, we can say that $\\langle a\\Lambda, \\vec{v} \\rangle = a\\langle \\Lambda, \\vec{v} \\rangle$, where $a$ is a scalar from $\\mathbb{F}$.\n \\item Zero vector: Consider the map which sends every vector to $0_\\mathbb{F}$; this can act as a `zero covector'.\n\\end{itemize}\n\n\\subsection{Dual Basis}\nWhen we create a vector space $V$ with basis $\\{\\vec{e}_\\mu\\}$, we automatically create a dual space $V^*$; since the dual space is also a vector space, it must have a basis. We call this basis $\\{\\vec{e}^\\mu\\}$, similar to the basis for the original vector space, but with a superscript index instead of a subscript.\nLike our choice for the basis of $V$, the choice of $\\{\\vec{e}^\\mu\\}$ is arbitrary.\nBut, while there isn't a specific basis created, we can choose our bases selectively.\nRemember that $\\vec{e}^\\mu$ are \\emph{linear maps} which can act upon $\\vec{e}_\\mu$;\nWe want to choose the basis for our dual space such that\n\\begin{align*}\n \\langle \\vec{e}^0, \\vec{e}_0 \\rangle &= 1, \\\\\n \\langle \\vec{e}^1, \\vec{e}_1 \\rangle &= 1, \\\\\n &\\vdots \\\\\n \\langle \\vec{e}^\\mu, \\vec{e}_\\mu \\rangle &= 1,\n\\end{align*}\nbut \n\\begin{align*}\n \\langle \\vec{e}^0, \\vec{e}_1 \\rangle &= 0, \\\\\n &\\vdots \\\\\n \\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle &= 0.\n\\end{align*}\nWe can generalize this statement to\n\\begin{align*}\n \\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle = \\delta^\\mu_\\nu,\n\\end{align*}\nwhere $\\delta^\\mu_\\nu$ is the Kronecker delta function,\n\\[\n \\delta^\\mu_\\nu =\n \\begin{cases}\n 1 & \\mu = \\nu \\\\\n 0 & \\mu \\not= \\nu\n \\end{cases}.\n\\]\nThis choice is also rather arbitrary --- we just like dealing with the case when $\\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle = 1$ if and only if $\\mu = \\nu$, and is zero otherwise. It's also important to realize that exactly \\emph{which} linear maps $\\{\\vec{e}^\\mu\\}$ are is not specified; although the creation of $V$ implies the creation of $V^*$, there isn't (yet) a way to relate vectors in $V$ to vectors in $V^*$.\n\n\\subsection{The Dual Dual Space}\nSince the dual space $V^*$ is a vector space in its own right, it too must have a dual space, the set of all linear maps which send a vector in $V^*$ to $\\mathbb{F}$.\nIf we look at the bracket notation for what we're really doing, it becomes obvious what this space must be:\n\\begin{align*}\n \\langle \\Lambda, \\cdot \\rangle &: V \\to \\mathbb{F} \\\\\n \\langle \\cdot, A^\\mu \\vec{e}_\\mu \\rangle &: V^* \\to \\mathbb{F}.\n\\end{align*}\nIf \\emph{covectors} go from $V$ to $\\mathbb{F}$, then \\emph{vectors} go from $V^*$ to $\\mathbb{F}$, so $V^{**} = V$.\nJust like how we can build any vector in $V$ using Einstein summation over the basis of $V$, we can build a basis for $V^*$ in the same way. Since the basis vectors for $V^*$ are of the form $\\{\\vec{e}^\\mu\\}$, we write an arbitrary vector in the dual space as\n\\[ \\Lambda = A_\\mu \\vec{e}^\\mu \\in V^*. \\]\nThis makes the above definition for linear maps\n\\begin{align*}\n \\langle A_\\mu \\vec{e}^\\mu, \\cdot \\rangle &: V \\to \\mathbb{F}, \\\\\n \\langle \\cdot, A^\\mu \\vec{e}_\\mu \\rangle &: V^* \\to \\mathbb{F}.\n\\end{align*}\n\n\\subsection{Covariance and Contravariance}\nIf we start with a vector space $V$ and its corresponding dual space $V^*$ (again, which is which is a rather arbitrary choice, sense \\emph{both} are vector spaces), we say that elements of the vector space $V$ are \\emph{vectors}, and they are said to vary \\emph{contravariantly}, while elements of the dual space $V^*$ are \\emph{covectors} which vary \\emph{contravariantly}.\n\n\\subsection{Arbitrary Vectors and Mappings}\nImagine we have an arbitrary covector $B^\\mu \\vec{e}_\\mu$, and an arbitrary vector $A_\\nu \\vec{e}^\\nu$ upon which this covector acts. We write this as \n\\[ \\langle B_\\mu \\vec{e}^\\mu, A^\\nu \\vec{e}_\\nu \\rangle. \\]\nSince these mappings are linear, we can factor out the coefficients, leaving\n\\[ B_\\mu A^\\nu \\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle. \\]\nSince we know that $\\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle = \\delta^\\mu_\\nu$, we can simplify this into\n\\[ B_\\mu A^\\nu \\langle \\vec{e}^\\mu, \\vec{e}_\\nu \\rangle = B_\\mu A^\\nu \\delta^\\mu_\\nu = B_\\mu A^\\mu. \\]\nThis means that we can refer to the result of the covector-vector applications by just the coefficients, as long as we define the dual basis by the delta function.\nNote also that $B_\\mu A^\\mu$ is a member of the field $\\mathbb{F}$ over which $V$ and $V^*$ are taken.", "meta": {"hexsha": "9fac936a1d29b31d916ad8181001242739dd01ea", "size": 5347, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/dual_space.tex", "max_stars_repo_name": "jopetty/tensor-notes", "max_stars_repo_head_hexsha": "64f3e51910118e6b031e9668a2b48a6af06c8600", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/dual_space.tex", "max_issues_repo_name": "jopetty/tensor-notes", "max_issues_repo_head_hexsha": "64f3e51910118e6b031e9668a2b48a6af06c8600", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/dual_space.tex", "max_forks_repo_name": "jopetty/tensor-notes", "max_forks_repo_head_hexsha": "64f3e51910118e6b031e9668a2b48a6af06c8600", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 71.2933333333, "max_line_length": 417, "alphanum_fraction": 0.668225173, "num_tokens": 1742, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088025362857, "lm_q2_score": 0.9099070048165069, "lm_q1q2_score": 0.8447656727610715}} {"text": "\\section{Brief primer on tensors}\\label{sec:tensor}\nThe material here is based on \\cite{lee-book-2000,dullemond-1991-tensor}.\n\n\nLet \\(V\\) be an \\(n\\)-dimensional vector space over the reals. A {\\em covector} on \\(V\\) is a real-valued linear functional \\(\\omega:V\\rightarrow \\Re\\). The space of all covectors is itself a real vector space under pointwise addition and multiplication. It is written as \\(V^{\\star}\\) and called the {\\em dual space} to \\(V\\). \n\n\\begin{proposition}[\\cite{lee-book-2000} Proposition 4.1] For \\(V\\) an \\(n\\)-dimensional vector space and \\(E_1, \\ldots, E_n\\) a basis for \\(V\\), the covectors \\(\\epsilon^1, \\ldots, \\epsilon^n\\), defined by:\n \\[\n \\epsilon^i(E_j) = \\delta^i_j = \\left\\{\n \\begin{array}{ll}\n 1 & \\mbox{if \\(i =j\\)} \\\\\n 0 & \\mbox{if \\(i\\not=j\\)}\n \\end{array}\\right.\n \\]\n\\noindent form a basis for \\(V^{\\star}\\), called the {\\em dual basis} to \\((E_i)\\). \n\\end{proposition}\n%% TODO: Define canonical isomorphism.\nNote that it follows that the dimensionality of \\(V^{\\star}\\) is the same as that of \\(V\\). It is also the case that \\(V^{\\star\\star}\\) is canonically isomorphic to \\(V\\). \n\n\n\\begin{definition}[Tensor] For $V$ a finite-dimensional real vector space, a {\\em tensor} of rank \\((k,l)\\) over $V$ is a real-valued multilinear function of $k$ elements of \\(V^{\\star}\\) and \\(l\\) elements of \\(V\\). \\(k\\) is said to be its {\\em contravariant} rank, and \\(l\\) its {\\em covariant} rank. The {\\em rank} of the tensor is \\(k+l\\).\n\\end{definition}\nA matrix \\(M\\) is a \\((1,1)\\)-tensor, a vector \\(x\\) a \\((1,0)\\)-tensor, and a covector \\{a\\} a \\((0,1)\\)-tensor.\n\nLet \\(\\{{\\bf e}_j\\}\\) be a basis for \\(V\\), with canonical cobasis \\(\\{\\epsilon^i\\}\\) for \\(V^{\\star}\\). \nSuch a tensor \\(T\\) can be associated with an array with \\(k+l\\) dimensions, whose \\((i_1, \\ldots, i_k, j_1, \\ldots, j_l)\\)'th element written \\(T^{i_1\\ldots i_k}_{j_1, \\ldots, j_l}\\) is given by \\(T(\\epsilon^{i_1}, \\ldots, \\epsilon^{i_k}, {\\bf e}_{j_1}, \\ldots, {\\bf e}_{j_l})\\).\n\nThe meaning of the indices of a tensor is usually decided beforehand; it is conventional to write a tensor with its contravariant (upper) indices first and the covariant (lower) indices last, e.g.{} \\(T^{i,j}_k\\). For instance, a matrix \\(M\\) is a \\((1,1)\\)-tensor, and we can write \\(M_i^j\\) to make its indices explicit. This is the same as \\(M_j^k\\) -- the identity of indices does not matter. Also, basis vectors will be written with a lower index, and components of a vector with respect to this basis with an upper index; similarly basis covectors will be written with an upper index and components of a covector with a lower index. \n\nDenote the set of all \\((k,l)\\)-tensors over \\(V\\) by \\(T^k_l\\).\n$T^k_l(V)$ is a vector space under point-wise addition and scalar multiplication. Specifically:\n\\[\n\\begin{array}{l}\n (\\alpha T)(X_1, \\ldots, X_k, Y_1, \\ldots, Y_l) = \\alpha(T(X_1, \\ldots, X_k, Y_1, \\ldots, Y_l))\\\\\n (S+T)(X_1, \\ldots, X_k, Y_1, \\ldots, Y_l)=S(X_1, \\ldots, X_K, Y_1, \\ldots, Y_k) + T(X_1, \\ldots, X_k, Y_1, \\ldots, Y_l)\n\\end{array}\n\\]\n\n\n\n\\subsection{Tensor Contraction}\\label{sec:summation-convention}\nIn the following we shall adopt the {\\em Einstein summation convention}:\n\\begin{quotation}\n If the same index name appears twice in any term, once as an upper index and once as a lower index, that term is understood to be summed over all possible values of that index, generally from \\(1\\) to the dimension of the space in question. If the indices belong to different tensors, their tensor product is taken first.\n\\end{quotation}\nThus for instance we can rewrite:\n\\[\n\\begin{array}{lcl}\n \\Sigma_{\\nu=1}^n A_{\\mu\\nu}v^{\\nu} & \\rightarrow & A_{\\mu\\nu}v_{\\nu}\\\\\n \\Sigma_{\\beta=1}^n \\Sigma_{\\gamma=1}^n A _{\\alpha \\beta}B^{\\beta \\gamma}C_{\\gamma \\delta} & \\rightarrow & A_{\\alpha \\beta}B^{\\beta \\gamma}C_{\\gamma \\delta}\n\\end{array}\n\\]\n\nThe {\\em contraction} of a tensor is obtained by setting one upper and one lower index equal, thus indicating a summation per the convention above. The result of contracting a \\((k,l)\\)-tensor is a \\((k-1,l-1)\\) tensor.\n\nThe contraction operation is invariant under coordinate changes.\n\n\n\\subsection{Working with tensors}\n \nTensors can be ``partially'' evaluated. For \\(T\\) a tensor of rank \\(k\\) representing a predicate \\(p\\), and \\(a\\) a vector representing the value of argument \\(i\\), \\(T_{1\\ldots k}a^i\\) represents the predicate \\(\\lambda x_1, \\ldots, x_{i-1},x_{i+1},\\ldots x_k. p(x_1, \\ldots, x_{i-1}, a, x_{i+1}, \\ldots, x_k)\\). It can be thought of as {\\em contracting} \\(T\\) and \\(a\\) on index \\(i\\).\n \n\n\\begin{example}\\label{ex:tc-1}\n Consider the tensor representation of the boolean polynomial \\(p(x,y) = x(1-y)\\). Because \\(x,y\\in \\{0,1\\}\\) with the two values independent of each other, we will embed them in the two dimensional vector space \\(U=\\{0,1\\}^2\\), with ``one hot'' basis vectors \\({\\bf e}_1=(1,0)\\) and \\({\\bf e}_2=(0,1)\\) representing \\(0\\) and \\(1\\) respectively. Now the tensor \\(T_{1,2}\\) representing the binary predicate \\(\\lambda x,y. p(x,y)\\) is represented by the table:\n \\[\n \\begin{array}{l}\n T({\\bf e}_1,{\\bf e}_1)=(0)(1-0)=0\\\\\n T({\\bf e}_1,{\\bf e}_2)=(0)(1-1)=0\\\\\n T({\\bf e}_2,{\\bf e}_1)=(1)(1-0)=1\\\\\n T({\\bf e}_2,{\\bf e}_2)=(1)(0)=0\n \\end{array}\n \\]\n We can use this representation to evaluate the predicate at different points through tensor contraction. For instance, \\(p(0,1)\\) is given, for \\(a={\\bf e}_1,b={\\bf e}_2\\) by \\(T_{1,2}a^1 b^2\\), which through the Einstein convention expands out to:\\footnote{Recall that for a vector \\(x\\) \\(x^j\\) represents its \\(j\\)th coordinate. Note that\n in the term \\(T_{1,2}a^1b^2\\) the super-scripts of \\(a\\) and \\(b\\) are indices, whereas in\n \\(T({\\bf e}_i,{\\bf e_j})a^i b^j\\) the super-scripts of \\(a\\) and \\(b\\) are component selections.}\n \\[\\begin{array}{ll}\n T_{1,2}a^1 b^2 &= \\Sigma_{j=1}^2 \\Sigma_{i=1}^2 T({\\bf e}_i,{\\bf e_j})a^i b^j \\\\\n &= T({\\bf e}_1,{\\bf e}_1)(1)(0) + T({\\bf e}_1,{\\bf e}_2)(1)(1) +\n T({\\bf e}_2,{\\bf e}_1)(0)(0) + T({\\bf e}_2,{\\bf e}_2)(0)(1) \\\\\n & =T({\\bf e}_1,{\\bf e}_2)\\\\\n & = 0\n \\end{array}\n \\]\n\\end{example}\n\nMore generally, we can compute tensor contraction symbolically. Let \\(x,y\\) be unknown vectors in \\(U\\), and let \\(S\\) be a rank-2 tensor over \\(U\\). Then if \\(S\\) represents the predicate \\(q\\), the predication \\(q(x,y)\\) is represented by \\(S_{1,2}x^1 y^2\\) which expands out to:\n\\[\\begin{array}{ll}\n [S(x,y)]&\\defeq S_{1,2}x^1 y^2\\\\\n & = \\Sigma_{j=1}^2 \\Sigma_{i=1}^2 S({\\bf e}_i,{\\bf e}_j)x^iy^j \\\\\n & =S({\\bf e}_1,{\\bf e}_1)x^1y^1 + S({\\bf e}_1,{\\bf e}_2)x^1y^2 +\n S({\\bf e}_2,{\\bf e}_1)x^2y^1 + S({\\bf e}_2,{\\bf e}_2)x^2y^2 \\\\\n \\end{array}\n\\]\n\n\\begin{example}[Example~\\ref{ex:tc-1} contd]\n Taking the value of \\(S\\) above to be \\(T\\), we get:\n \\[\\begin{array}{ll} \n [T(x,y)] & = x^2y^1\\\\\n & = [x=1][y=0]\n \\end{array}\n \\]\n\\end{example}\n\nThe representation of an arbitrary $k$-are predicate is similar, a tensor \\(T_k\\) represented by \\(n^k\\) numbers, for \\(U=\\{0,1\\}^n\\). \n", "meta": {"hexsha": "9281a3e1a8e6b9aaf36642b8c0e248408d684002", "size": 7034, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "appendix-tensor-2.tex", "max_stars_repo_name": "saraswat/logic-nn", "max_stars_repo_head_hexsha": "79af16ead7d86e4eca0b3cfc88d1c3379485088f", "max_stars_repo_licenses": ["CECILL-B"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-05-13T15:55:35.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-11T12:28:48.000Z", "max_issues_repo_path": "appendix-tensor-2.tex", "max_issues_repo_name": "saraswat/logic-nn", "max_issues_repo_head_hexsha": "79af16ead7d86e4eca0b3cfc88d1c3379485088f", "max_issues_repo_licenses": ["CECILL-B"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "appendix-tensor-2.tex", "max_forks_repo_name": "saraswat/logic-nn", "max_forks_repo_head_hexsha": "79af16ead7d86e4eca0b3cfc88d1c3379485088f", "max_forks_repo_licenses": ["CECILL-B"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 66.358490566, "max_line_length": 639, "alphanum_fraction": 0.6407449531, "num_tokens": 2509, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.936285007525904, "lm_q2_score": 0.9019206844384594, "lm_q1q2_score": 0.8444548148172315}} {"text": "\\section*{Problem 4 Solution}\n\nThe number density of material $i$ can be found using the formula\n$$ n_i = \\frac{\\rho_i N_A}{M_i} $$\nwhere $\\rho_i$ is the partial density of material $i$, $M_i$ is the molar mass of $i$, and $N_A$ is Avogadro's number. We can reverse this formula to find the partial density of a material from the atomic density.\n$$ \\rho_i = \\frac{N_i M_i}{N_A} $$\nWe can use this formula for the three isotopes we are considering. We also note the following:\n\\begin{itemize}\n\\item $n_{\\text{O}} = 2(n_{\\text{U5}} + n_{\\text{U5}})$\n\\item $M_{\\text{U5}} = 235.04\\text{ g/mol}$\n\\item $M_{\\text{U8}} = 238.05\\text{ g/mol}$\n\\item $M_{\\text{O}} = 16.00\\text{ g/mol}$\n\\end{itemize}\n\n\\begin{multicols}{2}\n$$ \\rho_{\\text{U5}} = \\frac{n_{\\text{U5}} M_{\\text{U5}} }{N_A} $$\n$$ \\rho_{\\text{U5}} = \\frac{(2.5\\times10^{21}\\text{ atoms/cm}^3)(235.04\\text{ g/mol}) }{6.022\\times10^{23}\\text{ atoms/mol}} $$\n$$\\boxed{ \\rho_{\\text{U5}} = 0.976\\text{ g/cm}^3 }$$\n\n\n$$ \\rho_{\\text{U8}} = \\frac{n_{\\text{U8}} M_{\\text{U8}} }{N_A} $$\n$$ \\rho_{\\text{U8}} = \\frac{(2.0\\times10^{22}\\text{ atoms/cm}^3)(238.05\\text{ g/mol}) }{6.022\\times10^{23}\\text{ atoms/mol}} $$\n$$\\boxed{ \\rho_{\\text{U8}} = 7.91\\text{ g/cm}^3 }$$\n\n\\end{multicols}\n\n$$ \\rho_{\\text{O}} = \\frac{n_{\\text{O}} M_{\\text{O}} }{N_A} $$\n$$ \\rho_{\\text{O}} = \\frac{2(n_{\\text{U5}} + n_{\\text{U5}}) M_{\\text{O}} }{N_A} $$\n$$ \\rho_{\\text{O}} = \\frac{2(2.25\\times10^{22}\\text{ atoms/cm}^{3})(16.00\\text{ g/mol}) }{6.022\\times10^{23}\\text{ atoms/mol}} $$\n$$\\boxed{ \\rho_{\\text{O}} = 1.20\\text{ g/cm}^3 }$$\n\nThe enrichment of $^{235}$U is therefore\n$\\frac{\\rho_{\\text{U5}}}{\\rho_{\\text{U5}}+\\rho_{\\text{U8}}} = 0.1098 \\quad\\Rightarrow \\quad\\boxed{10.98\\%}$\n\n", "meta": {"hexsha": "1bca5c422ebec71357270a3c4327d35c866fb67c", "size": 1709, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "exercises/drafts/disc02/disc02_solution04.tex", "max_stars_repo_name": "mitchnegus/NE150-discussion", "max_stars_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercises/drafts/disc02/disc02_solution04.tex", "max_issues_repo_name": "mitchnegus/NE150-discussion", "max_issues_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercises/drafts/disc02/disc02_solution04.tex", "max_forks_repo_name": "mitchnegus/NE150-discussion", "max_forks_repo_head_hexsha": "1d2afe0fc4830c3d13d491b9d6ccb7819083c5ad", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.8285714286, "max_line_length": 213, "alphanum_fraction": 0.6038619075, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.967899289579129, "lm_q2_score": 0.8723473730188542, "lm_q1q2_score": 0.8443444026111684}} {"text": "%!TEX root=ClassNotes.tex\n\n\\section{Taylor Series}\nTaylor series is a technique used to approximate functions using {\\it polynomials}.\n\n\\begin{definition}\n \\label{def:Taylor_series}\nFor a positive integer $n$, a real number $a$, and an infinitely differentiable function $f$, the {\\bf n$^{th}$ Taylor polynomial/approximation centered at $a$}, denoted $T_nf (x)$, is a degree $n$ polynomial defined as\\\\\n \\begin{align*}\n T_nf (x) &= f(a)\n + f'(a) \\cdot \\dfrac{(x-a)}{1}\n + f''(a) \\cdot \\dfrac{(x-a)^2}{2!}\n + \\dots\n + f^{(n)}(a) \\cdot \\dfrac{(x-a)^n}{n!}\\\\\n \\end{align*}\n where $f^{(n)}(a)$ denotes the $n^{th}$ derivative of $f$ at $a$.\\footnote{Recall that $n! = n \\cdot (n-1) \\cdot (n-2) \\cdots 2 \\cdot 1 $.}\nThe limit $n \\rightarrow \\infty$ of the above series is called the {\\bf Taylor series $Tf(x)$}.\\\\\n\\begin{align*}\n Tf(x) &= f(a)\n + f'(a) \\cdot \\dfrac{(x-a)}{1}\n + f''(a) \\cdot \\dfrac{(x-a)^2}{2!}\n + f^{(3)}(a) \\cdot \\dfrac{(x-a)^3}{3!}\n + \\dots\\\\\n\\end{align*}\n\\end{definition}\n\n\\begin{remark}\n The Taylor series defined above is just a {\\it formal series}.\n It is not always possible to plug in a value for $x$ because of convergence issues.\n We'll discuss this in the later sections.\n\\end{remark}\n\nWe'll mostly be interested in the Taylor series centered at $a = 0$, \\\\\n\\begin{align*}\n Tf(x)\n &=\n f(0)\n + f'(0) \\cdot \\dfrac{x}{1}\n + f''(0) \\cdot \\dfrac{x^2}{2!}\n + f^{(3)}(0) \\cdot \\dfrac{x^3}{3!}\n + \\dots\\\\\n\\end{align*}\nIn this case, $Tf(x)$ is called the $n^{th}$ {\\bf Maclaurin series}.\n\n\n\n\\begin{exercise}\n For each of the following functions compute $f^{(n)}(0)$, for positive integers $n$, and use these to compute the Maclaurin series.\n \\begin{multicols}{2}\n \\begin{enumerate}\n \\item $e^x$\n \\item $\\sin x$\n \\item $\\cos x$\n \\item $\\ln {(1+x)}$\n \\item $\\dfrac{1}{1-x}$\n \\item (Optional) $\\tan^{-1} x$\n \\end{enumerate}\n \\end{multicols}\n\\end{exercise}\n\n\\begin{exercise}\n This problem explains why the Definition \\ref{def:Taylor_series} is the ``correct'' definition for Taylor series.\n \\begin{enumerate}\n \\item Let $f(x) = x^k$. Compute $T_n f(x)$ centered at $0$ for\n \\begin{enumerate}\n \\item $n < k$\n \\item $n \\ge k$\n \\end{enumerate}\n \\item More generally, let\n \\begin{align*}\n f(x) = a_0 + a_1 x + a_2 x^2 + \\dots + a_k x^k\n \\end{align*}\n Using the previous part, compute $T_n f(x)$ for\n \\begin{enumerate}\n \\item $n < k$\n \\item $n \\ge k$\n \\end{enumerate}\n What is the Maclaurin series for this $f(x)$?\n \\end{enumerate}\n\\end{exercise}\nThe above statement is more generally for all Taylor series centered at any point $a$.\n\\begin{exercise}{\\bf (Optional)}\n Show that the Taylor series of $f(x) = x^n$, centered at a real number $a$, equals $x^n$. Argue that this is more generally true for an arbitrary polynomial $f(x)$.\n\\end{exercise}\n\n\\subsection{Remainder Term}\nAs mentioned earlier, Definition \\ref{def:Taylor_series} defines a \\textit{formal series} and it not possible to make sense of $Tf(x)$ for a real number $x$.\nThe two important questions that we need to answer are:\n\\begin{enumerate}\n \\item Does the limit $\\lim \\limits_{n \\rightarrow \\infty}T_n f(x)$ exist?\n \\item Does the limit $\\lim \\limits_{n \\rightarrow \\infty}T_n f(x)$ equal $f(x)$?\n\\end{enumerate}\nUnless the answer to both the questions is {\\it yes} it is not possible to use Taylor polynomials for approximating the function $f(x)$.\n\nBoth the questions are in generally difficult to answer.\nTo tackle the first question we need techniques from series and sequences.\nIn this section, we'll focus on answering the second question which can be done using basic Calculus.\n\n\n\\begin{definition}\n For a smooth function $f$ and real numbers $x$, $a$, the {\\bf $n^{th}$ error term} or the {\\bf $n^{th}$ remainder term $R_nf(x)$} is defined as\n \\begin{align*}\n R_nf(x)\n &= f(x) - T_nf(x)\n \\end{align*}\n where $T_n f(x)$ is the $n^{th}$ Taylor approximation of $f$ centered at $a$, so that $f(x) = T_nf(x) + R_nf(x)$.\nThus we can say that\n\\begin{align*}\n \\lim \\limits_{n \\rightarrow \\infty}T_n f(x) = f(x)\n\\end{align*}\nif and only if\n\\begin{align*}\n \\lim \\limits_{n \\rightarrow \\infty}R_n f(x) = 0.\n\\end{align*}\n\\end{definition}\n\n\\newpage\n\nThe following Theorem allows us to compute this remainder term using integrals.\n\\begin{theorem}\n \\label{thm:remainder_term}\n With the notation as above, the remainder term is given by\n \\begin{align*}\n R_nf(x) = \\dfrac{1}{n!} \\cdot \\int_a^x {(x-t)^n \\cdot {f^{(n+1)}(t)} } \\: dt\n \\end{align*}\n\\end{theorem}\n\n\\begin{exercise}\n \\begin{enumerate}\n \\item Using integration by parts (if necessary), compute\n \\begin{enumerate}\n \\item $\\int_0^x {f'(t)} \\: dt$\n \\item $\\int_0^x (x-t) \\cdot {f''(t)} \\: dt$\n \\item $\\int_0^x (x-t)^2 \\cdot {f^{(3)}(t)} \\: dt$\n \\end{enumerate}\n \\item{\\bf (Optional)} By repeatedly applying integration by parts, prove that\n \\begin{align*}\n \\dfrac{1}{n!} \\cdot \\int_0^x {(x-t)^n \\cdot {f^{(n+1)}(t)}} \\: dt\n \\end{align*}\n equals\n \\begin{align*}\n f(x) - \\left( f(0)\n + f'(0) \\cdot \\dfrac{x}{1}\n + f''(0) \\cdot \\dfrac{x^2}{2!}\n + \\dots\n + f^{(n)}(0) \\cdot \\dfrac{x^n}{n!}\n \\right)\n \\end{align*}\n thereby proving Theorem \\ref{thm:remainder_term} for $a=0$.\n \\end{enumerate}\n\\end{exercise}\n\n\\begin{exercise}{\\bf (Optional)}\n Prove Theorem \\ref{thm:remainder_term} for arbitrary real number $a$.\n\\end{exercise}\n\n\n\\newpage\n\\subsection{Computing using Taylor Series}\nWe can use the Taylor series (centered at 0) to do computations if\n\\begin{enumerate}\n \\item we can compute all the derivatives $f^{(n)}(0)$ for all positive integers $n$\n \\item $ \\lim \\limits_{n \\rightarrow \\infty}R_n f(x) = 0$.\n\\end{enumerate}\nThe condition $ \\lim \\limits_{n \\rightarrow \\infty}R_n f(x) = 0$ is highly non-trivial and not checking it leads to absurd results.\n\n\\begin{exercise}\n Let $f(x) = \\dfrac{1}{1-x}$.\n What happens to the value of the Maclaurin series $Tf(x)$ for $x=2$? What is $f(2)$?\n\\end{exercise}\nFor $f(x) = \\dfrac{1}{1-x}$ we can show that $ \\lim \\limits_{n \\rightarrow \\infty}R_n f(2) = \\infty$ (and not 0) and hence the difference between the Taylor series $Tf(2)$ and the function $f(2)$ blows up to infinity.\nIn the next section, we'll prove the following theorem which says that this does not happen for exponential and trigonometric functions.\n\\begin{theorem}\n \\label{thm:Taylor_series_exponential}\n If $f(x) = e^x$, $\\sin x$, and $\\cos x$, then $\\lim \\limits_{n \\rightarrow \\infty}R_n f(x) = 0$ for \\textit{all real numbers} x.\n\\end{theorem}\n\nHence, for all real numbers $x$, $\\lim \\limits_{n \\rightarrow \\infty}T_n f(x) = f(x)$ for exponential and trigonometric functions and we can use the Taylor series to approximate.\n\n\\begin{exercise}\n Use the Maclaurin series of $e^x$ to compute the value of $e$ correct up to 2 decimal places.\n\\end{exercise}\n\n\\begin{exercise}\n \\begin{enumerate}\n \\item Theorem \\ref{thm:Taylor_series_exponential} is also true for $\\tan^{-1} x$, the proof is easy but technical. The Maclaurin series of $\\tan^{-1} x$ is given by\n \\begin{align*}\n x - \\dfrac{x^3}{3} + \\dfrac{x^5}{5} - \\dfrac{x^7}{7} + \\dfrac{x^9}{9} + - \\dots\n \\end{align*}\n Using this find an expression (as an infinite sum) for $\\pi$.\\hint{Use $x = 1$.}\n \\item Use the first 10 terms of this sum to find an approximate value for $\\pi$.\n This method for computing $\\pi$ is not used in practice as the \\textit{rate of convergence} of the Maclaurin series is very slow.\n \\end{enumerate}\n\\end{exercise}\n\n\\begin{exercise}\n Theorem \\ref{thm:Taylor_series_exponential} is true even if $x$ is a complex number (the proof requires complex analysis).\n Compute the Taylor series of $e^{i\\theta}$, $\\cos \\theta$, $\\sin \\theta$. Use these to prove the {\\it Euler's identity},\n\\begin{align*}\n e^{i\\theta} &= \\cos \\theta + i \\sin \\theta\n\\end{align*}\n\\end{exercise}\n\n\n\n\\subsection{Estimating the Remainder Term}\nFinally, we want to prove Theorem \\ref{thm:Taylor_series_exponential}.\n\n\\begin{exercise} {\\bf (Optional)}\n Let $x$ be a positive real number.\n For each of the following functions $f(x)$, show that there is a constant $M$ such that for all $ t \\in (0,x)$ and all positive integers $n$ we have $|f^{(n)}(t)| < M$. (Note that $M$ can depend on $x$ but not on $n$ or $t$.)\n \\begin{multicols}{2}\n \\begin{enumerate}\n \\item $e^x$\n \\item $\\sin x$\n \\item $\\cos x$\n \\end{enumerate}\n \\end{multicols}\n\\end{exercise}\nUsing the above problem, the proof of Theorem \\ref{thm:Taylor_series_exponential} will be complete once we prove the following Proposition.\n\\begin{prop}\n Let $x$ be a positive real number. If there is a real number $M$ such that for all $ t \\in (0,x)$ and all positive integers $n$ we have $|f^{(n)}(x)| < M$ then $R_n f(x) \\rightarrow 0$ as $n \\rightarrow \\infty$.\n\\end{prop}\n\\begin{proof}\n By definition,\n \\begin{align*}\n R_n f(x) = \\dfrac{1}{n!} \\cdot \\int_0^x {(x-t)^n \\cdot {f^{(n+1)}(t)}} \\: dt\n \\end{align*}\n Because $(x-t)^n < x^n$ and $|f^{(n+1)}(t)| < M$ for all $0 < t < x$ and all positive integers $n$, we get\n \\begin{align*}\n |R_n f(x)|\n &=\n \\left|\\dfrac{1}{n!} \\cdot \\int_0^x {(x-t)^n \\cdot {f^{(n+1)}(t)}} \\: dt \\right|\\\\\n &< \\left|\\dfrac{1}{n!} \\cdot \\int_0^x x^n \\cdot M \\: dt \\right| \\\\\n &= \\left|\\dfrac{1}{n!} \\cdot x^n \\cdot M \\int_0^x 1 \\: dt \\right| \\\\\n &= \\left|\\dfrac{1}{n!} \\cdot x^n \\cdot M x \\right| \\\\\n &= \\dfrac{M x^{n+1}}{n!}\n \\end{align*}\n One can show that for any real number $x$, $\\lim \\limits_{n \\rightarrow \\infty} x^{n+1} / n! = 0$ (this is easy, see if you can work out the details) so that\n\\begin{align*}\n \\lim \\limits_{n \\rightarrow \\infty} |R_n f(x)|\n &<\n \\lim \\limits_{n \\rightarrow \\infty} \\dfrac{M x^{n+1}}{n!}\n \\\\\n &= {M}\\cdot \\lim \\limits_{n \\rightarrow \\infty} \\dfrac{x^{n+1}}{n!} \\\\\n &= M \\cdot 0 = 0\n\\end{align*}\n\\end{proof}\n\nTo summarize, Taylor series provides us a tool for approximating functions using polynomials (in the cases where the remainder term tends to 0).\nThis is a very common technique in analysis: we try to approximate a function by a series of simpler functions and show that the difference between the two tends to 0.\nFourier series, for example, does this using trigonometric functions.\n", "meta": {"hexsha": "28efde8703bc0862b5ce297f024e82b9311394aa", "size": 10339, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "2018/11Taylor.tex", "max_stars_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_stars_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2018/11Taylor.tex", "max_issues_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_issues_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2018/11Taylor.tex", "max_forks_repo_name": "apurvnakade/jhu2017-18-honors-single-variable-calculus", "max_forks_repo_head_hexsha": "5b6cb3dde364990abe868ce155a697dce78302fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8656126482, "max_line_length": 229, "alphanum_fraction": 0.645807138, "num_tokens": 3495, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248242542283, "lm_q2_score": 0.8991213847035618, "lm_q1q2_score": 0.8442973002544806}} {"text": "%----------------------------------------------------------------------------------------\n%\tCHAPTER 2\n%----------------------------------------------------------------------------------------\n\n\\chapter{In-text Elements}\n\n\\section{Theorems}\\index{Theorems}\n\nThis is an example of theorems.\n\n\\subsection{Several equations}\\index{Theorems!Several Equations}\nThis is a theorem consisting of several equations.\n\n\\begin{theorem}[Name of the theorem]\nIn $E=\\mathbb{R}^n$ all norms are equivalent. It has the properties:\n\\begin{align}\n& \\big| ||\\mathbf{x}|| - ||\\mathbf{y}|| \\big|\\leq || \\mathbf{x}- \\mathbf{y}||\\\\\n& ||\\sum_{i=1}^n\\mathbf{x}_i||\\leq \\sum_{i=1}^n||\\mathbf{x}_i||\\quad\\text{where $n$ is a finite integer}\n\\end{align}\n\\end{theorem}\n\n\\subsection{Single Line}\\index{Theorems!Single Line}\nThis is a theorem consisting of just one line.\n\n\\begin{theorem}\nA set $\\mathcal{D}(G)$ in dense in $L^2(G)$, $|\\cdot|_0$. \n\\end{theorem}\n\n%------------------------------------------------\n\n\\section{Definitions}\\index{Definitions}\n\nThis is an example of a definition. A definition could be mathematical or it could define a concept.\n\n\\begin{definition}[Definition name]\nGiven a vector space $E$, a norm on $E$ is an application, denoted $||\\cdot||$, $E$ in $\\mathbb{R}^+=[0,+\\infty[$ such that:\n\\begin{align}\n& ||\\mathbf{x}||=0\\ \\Rightarrow\\ \\mathbf{x}=\\mathbf{0}\\\\\n& ||\\lambda \\mathbf{x}||=|\\lambda|\\cdot ||\\mathbf{x}||\\\\\n& ||\\mathbf{x}+\\mathbf{y}||\\leq ||\\mathbf{x}||+||\\mathbf{y}||\n\\end{align}\n\\end{definition}\n\n%------------------------------------------------\n\n\\section{Notations}\\index{Notations}\n\n\\begin{notation}\nGiven an open subset $G$ of $\\mathbb{R}^n$, the set of functions $\\varphi$ are:\n\\begin{enumerate}\n\\item Bounded support $G$;\n\\item Infinitely differentiable;\n\\end{enumerate}\na vector space is denoted by $\\mathcal{D}(G)$. \n\\end{notation}\n\n%------------------------------------------------\n\n\\section{Remarks}\\index{Remarks}\n\nThis is an example of a remark.\n\n\\begin{remark}\nThe concepts presented here are now in conventional employment in mathematics. Vector spaces are taken over the field $\\mathbb{K}=\\mathbb{R}$, however, established properties are easily extended to $\\mathbb{K}=\\mathbb{C}$.\n\\end{remark}\n\n%------------------------------------------------\n\n\\section{Corollaries}\\index{Corollaries}\n\nThis is an example of a corollary.\n\n\\begin{corollary}[Corollary name]\nThe concepts presented here are now in conventional employment in mathematics. Vector spaces are taken over the field $\\mathbb{K}=\\mathbb{R}$, however, established properties are easily extended to $\\mathbb{K}=\\mathbb{C}$.\n\\end{corollary}\n\n%------------------------------------------------\n\n\\section{Propositions}\\index{Propositions}\n\nThis is an example of propositions.\n\n\\subsection{Several equations}\\index{Propositions!Several Equations}\n\n\\begin{proposition}[Proposition name]\nIt has the properties:\n\\begin{align}\n& \\big| ||\\mathbf{x}|| - ||\\mathbf{y}|| \\big|\\leq || \\mathbf{x}- \\mathbf{y}||\\\\\n& ||\\sum_{i=1}^n\\mathbf{x}_i||\\leq \\sum_{i=1}^n||\\mathbf{x}_i||\\quad\\text{where $n$ is a finite integer}\n\\end{align}\n\\end{proposition}\n\n\\subsection{Single Line}\\index{Propositions!Single Line}\n\n\\begin{proposition} \nLet $f,g\\in L^2(G)$; if $\\forall \\varphi\\in\\mathcal{D}(G)$, $(f,\\varphi)_0=(g,\\varphi)_0$ then $f = g$. \n\\end{proposition}\n\n%------------------------------------------------\n\n\\section{Examples}\\index{Examples}\n\nThis is an example of examples.\n\n\\subsection{Equation and Text}\\index{Examples!Equation and Text}\n\n\\begin{example}\nLet $G=\\{x\\in\\mathbb{R}^2:|x|<3\\}$ and denoted by: $x^0=(1,1)$; consider the function:\n\\begin{equation}\nf(x)=\\left\\{\\begin{aligned} & \\mathrm{e}^{|x|} & & \\text{si $|x-x^0|\\leq 1/2$}\\\\\n& 0 & & \\text{si $|x-x^0|> 1/2$}\\end{aligned}\\right.\n\\end{equation}\nThe function $f$ has bounded support, we can take $A=\\{x\\in\\mathbb{R}^2:|x-x^0|\\leq 1/2+\\epsilon\\}$ for all $\\epsilon\\in\\intoo{0}{5/2-\\sqrt{2}}$.\n\\end{example}\n\n\\subsection{Paragraph of Text}\\index{Examples!Paragraph of Text}\n\n\\begin{example}[Example name]\n\\lipsum[2]\n\\end{example}\n\n%------------------------------------------------\n\n\\section{Exercises}\\index{Exercises}\n\nThis is an example of an exercise.\n\n\\begin{exercise}\nThis is a good place to ask a question to test learning progress or further cement ideas into students' minds.\n\\end{exercise}\n\n%------------------------------------------------\n\n\\section{Problems}\\index{Problems}\n\n\\begin{problem}\nWhat is the average airspeed velocity of an unladen swallow?\n\\end{problem}\n\n%------------------------------------------------\n\n\\section{Vocabulary}\\index{Vocabulary}\n\nDefine a word to improve a students' vocabulary.\n\n\\begin{vocabulary}[Word]\nDefinition of word.\n\\end{vocabulary}\n\n\n", "meta": {"hexsha": "fc5c759b2d701452d9a03debd9029021d1d0ecc9", "size": 4712, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapter2.tex", "max_stars_repo_name": "karthikpoduval/camera-software-demystified", "max_stars_repo_head_hexsha": "904a28ebab51b1c5b1366bfdf8c81b2b2c3710fa", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter2.tex", "max_issues_repo_name": "karthikpoduval/camera-software-demystified", "max_issues_repo_head_hexsha": "904a28ebab51b1c5b1366bfdf8c81b2b2c3710fa", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter2.tex", "max_forks_repo_name": "karthikpoduval/camera-software-demystified", "max_forks_repo_head_hexsha": "904a28ebab51b1c5b1366bfdf8c81b2b2c3710fa", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.2052980132, "max_line_length": 222, "alphanum_fraction": 0.6120543294, "num_tokens": 1378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541577509315, "lm_q2_score": 0.8962513759047847, "lm_q1q2_score": 0.8439588345107335}} {"text": "%-----------------------------------\n\\subsection{The conic frustrum}\n%-----------------------------------\nThe derivation of the surface area of conic frustrum.\nThe edge length $l$ is defined\n\\begin{equation}\n l = \\sqrt{(x_r - x_l)^2 + (a_r - a_l)^2} = \\sqrt{\\Delta x^2 + \\Delta a^2}.\n\\end{equation}\nThe lateral area of the surface is found by integrating along surface of rotation:\n\\begin{align}\n \\sigma_{\\text{lateral}}\n &= \\int_{0}^{l} {2\\pi a(s)} \\deriv{s} \\nonumber \\\\\n &= 2\\pi \\int_{0}^{l} {a_{\\ell} + \\frac{s}{l}\\left( a_r - a_\\ell \\right)} \\deriv{s} \\nonumber \\\\\n &= 2\\pi \\left[ a_{\\ell}s + \\frac{s^2}{2l}\\left( a_r - a_\\ell \\right) \\right]_0^l \\nonumber \\\\\n &= \\pi l \\left( a_{\\ell} + a_r \\right) \\nonumber \\\\\n &= \\pi \\left( a_{\\ell} + a_r \\right) \\sqrt{\\Delta x^2 + \\Delta a^2}. \\label{eq:frustrum_area}\n\\end{align}\n\nThere are two degenerate cases of interest. The first is the \\emph{cylinder}, for which the radii at each end are euqal, i.e. $a_\\ell = a_r = a$. In this case the lateral area of the surface is\n\\begin{equation}\n \\sigma_{\\text{lateral}} = 2\\pi a \\Delta x.\n\\end{equation}\nThe second is a cone, for which $a_\\ell=0$ and $a_r=a$:\n\\begin{equation}\n \\sigma_{\\text{lateral}} = \\pi a \\sqrt{\\Delta x^2 + a^2}.\n\\end{equation}\n", "meta": {"hexsha": "81a04377c2f6db62dc7f51e03705b21a6d657a9a", "size": 1289, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/math/model/appendix.tex", "max_stars_repo_name": "kabicm/arbor", "max_stars_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/math/model/appendix.tex", "max_issues_repo_name": "kabicm/arbor", "max_issues_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-03-26T16:29:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-27T13:41:49.000Z", "max_forks_repo_path": "doc/math/model/appendix.tex", "max_forks_repo_name": "kabicm/arbor", "max_forks_repo_head_hexsha": "cfab5fd6a2e6a211c097659c96dcc098ee806e68", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-07-06T11:07:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-06T11:07:13.000Z", "avg_line_length": 47.7407407407, "max_line_length": 193, "alphanum_fraction": 0.5896043445, "num_tokens": 449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9693241991754918, "lm_q2_score": 0.8705972684083609, "lm_q1q2_score": 0.8438910000043052}} {"text": "\\lab{Introduction to Matplotlib}{Matplotlib}\n\\label{lab:Matplotlib}\n\\objective{\nMatplotlib is the most commonly-used data visualization library in Python. Being able to visualize data helps to determine patterns, to communicate results, and is a key component of applied and computational mathematics.\nIn this lab we introduce techniques for visualizing data in 1, 2, and 3 dimensions.\nThe plotting techniques presented here will be used in the remainder of the labs in the manual.\n}\n\n\\section*{Line Plots} % =======================================================\n\nThe quickest way to visualize a simple 1-dimensional array is via a \\emph{line plot}.\nThe following code creates an array of outputs of the function $f(x) = x^2$, then visualizes the array using the \\li{matplotlib} module.\\footnote{Like NumPy, Matplotlib is \\emph{not} part of the Python standard library, but it is included in most Python distributions.}\n\n\\begin{lstlisting}\n>>> import numpy as np\n>>> from matplotlib import pyplot as plt\n\n>>> y = np.arange(-5,6)**2\n>>> y\narray([25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25])\n\n# Visualize the plot.\n>>> plt.plot(y) # Draw the line plot.\n<<[]>>\n>>> plt.show() # Reveal the resulting plot.\n\\end{lstlisting}\n\nThe result is shown in Figure \\ref{fig:basic1}.\nJust as \\li{np} is a standard alias for NumPy, \\li{plt} is a standard alias for \\li{matplotlib.pyplot} in the Python community.\n\nThe call \\li{plt.plot(y)} creates a figure and draws straight lines connecting the entries of \\li{y} relative to the $y$-axis.\nThe $x$-axis is by default the index of the array, namely the integers from $0$ to $10$.\nCalling \\li{plt.show()} then displays the figure.\n\n\\begin{figure}[H] % plt.plot(y) compared to plt.plot(x,y).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.5\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/basic1.pdf}\n \\caption{\\li{plt.plot(y)} uses the indices of\\\\the array for the $x$-axis.}\n \\label{fig:basic1}\n\\end{subfigure}%\n\\begin{subfigure}{.5\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/basic2.pdf}\n \\caption{\\li{plt.plot(x,y)} specifies both the\\\\domain and the range.}\n \\label{fig:basic2}\n\\end{subfigure}\n\\caption{Simple plots of $f(x) = x^2$ over the interval $x\\in[-5,5]$.}\n\\end{figure}\n\n\\begin{problem} % Law of Large Numbers / NumPy review.\nWrite a function that accepts an integer $n$ as input.\n\\begin{enumerate}\n\\item Use \\li{np.random.randn()} or \\li{np.random.normal()} to create an $n\\times n$ array of values randomly sampled from the standard normal distribution.\n\\item Compute the mean of each row of the array.\n\\\\(Hint: use \\li{np.mean()} and specify the \\li{axis} keyword argument.)\n\\item Return the variance of these means.\n\\\\(Hint: use \\li{np.var()} to calcualte the variance).\n\\end{enumerate}\nDefine a new function that creates an array of the results of the first function with inputs $n = 100,\\ 200,\\ \\ldots,\\ 1000$.\nPlot (and show) the resulting array.\n\nThis result illustrates one version of the \\emph{Law of Large Numbers}.\n\\end{problem}\n\n\\subsection*{Specifying a Domain} % -----------------------------------------\n\nAn obvious problem with Figure \\ref{fig:basic1} is that the $x$-axis does not correspond correctly to the $y$-axis for the function $f(x) = x^2$ that is being drawn.\nTo correct this, we need an array for the domain as well as one for the range.\nFirst define an array \\li{x} for the domain, then use that array to calculate the range \\li{y} of $f$.\nThe command \\li{plt.plot(x,y)} then plots \\li{x} against \\li{y}.\nThat is, each point \\li{(x[i], y[i])} is drawn and consecutive points are connected.\n% Thus both arrays must have the same number of elements to be compatible.\n\nAnother problem with Figure \\ref{fig:basic1} is its poor resolution; the curve is visibly bumpy, especially near the bottom of the curve.\nNumPy's \\li{np.linspace()} function makes it easy to get a higher-resolution domain.\nRecall that \\li{range()} and \\li{np.arange()} return a list or array of evenly-spaced values in a given interval, where the \\emph{spacing} between the entries is specified.\nIn contrast, \\li{np.linspace()} creates an array of evenly-spaced values in a given interval where the \\emph{number of elements} is specified.\n\n\\begin{lstlisting}\n# 4 evenly-spaced values between 0 and 32 (including endpoints).\n>>> np.linspace(0, 32, 4)\narray([ 0. , 10.66666667, 21.33333333, 32. ])\n\n# Get 50 evenly-spaced values from -5 to 5 (including endpoints).\n>>> x = np.linspace(-5, 5, 50)\n>>> y = x**2 # Calculate the range of f(x) = x**2.\n>>> plt.plot(x, y)\n>>> plt.show()\n\\end{lstlisting}\n\nThe resulting plot is shown in Figure \\ref{fig:basic2}.\nNote that this time, the $x$-axis is correctly aligned with the $y$-axis.\nThe resolution is also much better because \\li{x} and \\li{y} have $50$ entries each instead of only $10$.\n\nAll calls to \\li{plt} functions modify the same figure until \\li{plt.show()} is executed, which displays the current figure and resets the system.%\n\\footnote{Use \\li{plt.figure()} to manually create several figures at once.}\nThe next time a \\li{plt} function is called a new figure is created.\nThis makes it possible to plot several lines in a single figure.\n\n\n\\begin{problem} % Plot two lines (sin() and cos()).\nWrite a function that plots the functions $\\sin(x)$, $\\cos(x)$, and $\\arctan(x)$ on the domain $[-2\\pi, 2\\pi]$ (use \\li{np.pi} for $\\pi$).\n% Call \\li{plt.xlim(-2*np.pi, 2*np.pi)} before \\li{plt.show()} to stretch the $x$-axis appropriately.\nMake sure the domain is refined enough to produce a figure with good resolution.\n\\end{problem}\n\n\\begin{info} % Interactive Mode.\nPlotting can seem a little mystical because the actual plot doesn't appear until \\li{plt.show()} is executed.\nMatplotlib's \\emph{interactive mode} allows the user to see the plot be constructed one piece at a time.\nUse \\li{plt.ion()} to turn interactive mode on and \\li{plt.ioff()} to turn it off.\nThis is very useful for quick experimentation.\n\nTry executing the following commands in IPython:\n\n\\begin{lstlisting}\nIn [1]: import numpy as np\nIn [2]: from matplotlib import pyplot as plt\n\n# Turn interactive mode on and make some plots.\nIn [3]: plt.ion()\nIn [4]: x = np.linspace(1, 4, 100)\nIn [5]: plt.plot(x, np.log(x))\nIn [6]: plt.plot(x, np.exp(x))\n\n# Clear the figure, then turn interactive mode off.\nIn [7]: plt.clf()\nIn [8]: plt.ioff()\n\\end{lstlisting}\n\nUse interactive mode \\textbf{only} with IPython.\nUsing interactive mode in a non-interactive setting may freeze the window or cause other problems.\n\\end{info}\n\n\\section*{Plot Customization} % ===============================================\n\n\\li{plt.plot()} receives several keyword arguments for customizing the drawing.\nFor example, the color and style of the line are specified by the following string arguments.\n%\n\\begin{table}[H] % Color and style.\n\\begin{tabular}{r|l}\n Key & Color \\\\\n \\hline\n \\li{'b'} & blue\\\\\n \\li{'g'} & green\\\\\n \\li{'r'} & red\\\\\n \\li{'c'} & cyan\\\\\n \\li{'m'} & magenta\\\\\n % \\li{'y'} & yellow\\\\\n \\li{'k'} & black\\\\\n % \\li{'w'} & white\n\\end{tabular}\n\\qquad\n\\begin{tabular}{r|l}\n Key & Style \\\\\n \\hline\n \\li{'-'} & solid line\\\\\n \\li{'--'} & dashed line\\\\\n \\li{'-.'} & dash-dot line\\\\\n \\li{':'} & dotted line\\\\\n % \\li{'.'} & point marker\\\\\n \\li{'o'} & circle marker\\\\\n % \\li{'*'} & star marker\\\\\n \\li{'+'} & plus marker\n\\end{tabular}\n\\end{table}\n\nSpecify one or both of these string codes as an argument to \\li{plt.plot()} to change from the default color and style.\nOther \\li{plt} functions further customize a figure.\n%\n\\begin{table}[H]\n\\centering\n\\begin{tabular}{r|l}\n Function & \\multicolumn{1}{|c}{Description}\\\\\n \\hline\n % \\li{grid()} & Add grid lines\\\\\n \\li{legend()} & Place a legend in the plot\\\\\n % \\li{text()} & Add text at a given position on the plot\\\\\n \\li{title()} & Add a title to the plot\\\\\n \\li{xlim()} & Set the limits of the $x$-axis\\\\\n \\li{ylim()} & Set the limits of the $y$-axis\\\\\n % \\li{xticks()} & set the location of the tick marks on the x axis, returns current locations if no arguments are given\\\\\n % \\li{yticks()} & set the location of the tick marks on the y axis, returns current locations if no arguments are given\\\\\n \\li{xlabel()} & Add a label to the $x$-axis\\\\\n \\li{ylabel()} & Add a label to the $y$-axis\n\\end{tabular}\n\\end{table}\n\n\\begin{lstlisting}\n>>> x1 = np.linspace(-2, 4, 100)\n>>> plt.plot(x1, np.exp(x1), 'g:', linewidth=6, label=\"Exponential\")\n>>> plt.title(\"This is the title.\", fontsize=18)\n>>> plt.legend(loc=\"upper left\") # plt.legend() uses the 'label' argument of\n>>> plt.show() # plt.plot() to create a legend.\n\n>>> x2 = np.linspace(1, 4, 100)\n>>> plt.plot(x2, np.log(x2), 'r+', markersize=4)\n>>> plt.xlim(0, 5) # Set the visible limits of the x axis.\n>>> plt.xlabel(\"The x axis\") # Give the x axis a label.\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H] % Figure customizations.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/custom1.pdf}\n \\label{fig:custom1}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/custom2.pdf}\n \\label{fig:custom2}\n\\end{subfigure}\n\\label{fig:custom}\n\\end{figure}\n\nSee Appendix \\ref{mpltables} for more comprehensive lists of colors, line styles, and figure customization routines.\n\n\\begin{problem} % Line plots with different domains but uniform style.\nWrite a function to plot the curve $f(x) = \\frac{1}{x-1}$ on the domain $[-2,6]$.\nAlthough $f(x)$ has a discontinuity at $x=1$, a single call to \\li{plt.plot()} will attempt to make the curve look continuous.\n\\begin{enumerate}\n\\item Split up the domain and plot the two sides of the curve separately so that the graph looks discontinuous at $x=1$.\n\\item Plot both curves with a thick, dashed magenta line.\\\\\nThe keyword arguments \\li{linewidth} or \\li{lw} specify the line thickness.\n\\item Change the range of the $y$-axis to be $[-6, 6]$.\n\\end{enumerate}\nThe plot should resemble the figure below.\n\n\\begin{figure}[H] % Solution.\n\\includegraphics[width=.5\\textwidth]{figures/discontinuousProblem.pdf}\n\\end{figure}\n\\end{problem}\n\n\\subsection*{Subplots} % ------------------------------------------------------\n\n\\emph{Subplots} are non-overlapping plots arranged in a grid within a single figure.\nTo create a figure with a grid of subplots, use \\li{plt.subplot(numrows, numcols, fignum)}.\nHere, \\li{numrows} is the number of rows of subplots in the figure, \\li{numcols} is the number of columns, and \\li{fignum} specifies which subplot to modify.\n% This index starts at 1 and increments across rows first.\nSee Figure \\ref{fig:subplots-layout}.\n\n\\begin{figure}[H] % The layout created by subplots(23i).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_1.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_2.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_3.pdf}\n\\end{subfigure}\n\\\\\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_4.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_5.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.15\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/layout_6.pdf}\n\\end{subfigure}\n\\caption{The layout of subplots with \\li{plt.subplot(2,3,i)} (2 rows, 3 columns), where \\li{i} is the index pictured above.}\n\\label{fig:subplots-layout}\n\\end{figure}\n\nIf the inputs for \\li{plt.subplot()} are all integers, the commas between the entries can be omitted.\nFor example, \\li{plt.subplot(3,2,2)} and \\li{plt.subplot(322)} are equivalent.\n\n\\begin{lstlisting}\n>>> x = np.linspace(.1, 2, 200)\n\n>>> plt.subplot(121) # Start drawing the first subplot.\n>>> plt.plot(x, np.exp(x), 'k', lw=2)\n>>> plt.plot(x, np.exp(2*x), 'b', lw=2)\n>>> plt.title(\"Exponential\", fontsize=18)\n\n>>> plt.subplot(122) # Start drawing the second subplot.\n>>> plt.plot(x, np.log(x), 'k', lw=2)\n>>> plt.plot(x, np.log(2*x), 'b', lw=2)\n>>> plt.title(\"Logarithmic\", fontsize=18)\n\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H] % The layout created by plt.subplot(23i).\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/subplots_1.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/subplots_2.pdf}\n\\end{subfigure}\n\\end{figure}\n\n\\begin{problem} % Subplots of sine functions.\nWrite a function that plots the functions $\\sin(x)$, $\\sin(2x)$, $2\\sin(x)$, and $2\\sin(2x)$ on the domain $[0, 2\\pi]$, each in a separate subplot.\n\\begin{enumerate}\n \\item Arrange the plots in a square grid of 4 subplots.\n \\item Set the limits of each subplot to $[0, 2\\pi]\\times[-2,2]$.\n \\\\(Hint: \\li{plt.axis()} can do this in one line, instead of using both\n \\\\\\li{plt.xlim()} and \\li{plt.ylim()}.)\n \\item Use \\li{plt.title()} to give each subplot an appropriate title.\n \\item Use \\li{plt.suptitle()} to give the overall figure a title.\n \\item Use the following colors and line styles.\n \\begin{align*}\\begin{array}{rcl}\n \\sin(x)\\text{: green solid line.} && \\sin(2x)\\text{: red dashed line.}\\\\ \\\\\n 2\\sin(x)\\text{: blue dashed line.} && 2\\sin(2x)\\text{: magenta dotted line.}\n \\end{array}\\end{align*}\n\\end{enumerate}\n\\end{problem}\n\n\\section*{Other Kinds of Plots} % =============================================\n\nLine plots are not always the most illuminating choice graph to describe a set of data.\nMatplotlib provides several other easy ways to visualize data.\n\n\\begin{itemize}\n\\item A \\emph{scatter plot} plots two 1-dimensional arrays against each other without drawing lines between the points.\nScatter plots are particularly useful for data that is not inherently correlated or ordered.\n\nTo create a scatter plot, use \\li{plt.plot()} and specify a point marker (such as \\li{'o'} or \\li{'+'}) for the line style.%\n\\footnote{\\li{plt.scatter()} can also be used to create scatter plots, but it accepts slightly different arguments than \\li{plt.plot()}. We will explore the appropriate usage of this function in a later lab.}\n\n\\item A \\emph{histogram} groups entries of a 1-dimensional data set into a given number of intervals, called \\emph{bins}.\nEach bin has a bar whose height indicates the number of values that fall in the range of the bin.\n% The more bins, the greater the detail, but having too many bins can also destroy the picture by creating interval gaps between values.\nHistograms are best for displaying distributions, relating data values to frequency.\n\nTo create a histogram, use \\li{plt.hist()} instead of \\li{plt.plot()}.\nUse the argument \\li{bins} to specify the edges of the bins, or to choose a number of bins.\nThe \\li{<>} argument specifies the outer limits of the first and last bins.\n\\end{itemize}\n\n\\begin{lstlisting}\n# Get 500 random samples from two normal distributions.\n>>> x = np.random.normal(scale=1.5, size=500)\n>>> y = np.random.normal(scale=0.5, size=500)\n\n# Draw a scatter plot of x against y, using a circle marker.\n>>> plt.subplot(121)\n>>> plt.plot(x, y, 'o', markersize=10)\n\n# Draw a histogram to display the distribution of the data in x.\n>>> plt.subplot(122)\n>>> plt.hist(x, bins=np.arange(-4.5, 5.5)) # Or, equivalently,\n# plt.hist(x, bins=9, range=[-4.5, 4.5])\n\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/scatterplot.pdf}\n\\end{subfigure}\n%\n\\begin{subfigure}{.49\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/histogram.pdf}\n\\end{subfigure}\n\\end{figure}\n\n% On the histogram, specifying 9 bins in the range $[-4.5, 4.5]$ creates a bin centered over each integer from $-4$ to $4$.\n\n\\begin{problem} % FARS data visualization.\nThe Fatality Analysis Reporting System (FARS) is a nationwide census providing yearly data regarding fatal injuries suffered in motor vehicle traffic crashes.%\n\\footnote{See \\url{http://www.nhtsa.gov/FARS}.}\nThe array contained in \\texttt{FARS.npy} is a small subset of the FARS database from 2010--2014.\nEach of the 148,206 rows in the array represents a different car crash; the columns represent the hour (in military time, as an integer), the longitude, and the latitude, in that order.\n\nWrite a function to visualize the data in \\texttt{FARS.npy}.\nUse \\li{np.load()} to load the data, then create a single figure with two subplots:\n%\n\\begin{enumerate}\n\\item A scatter plot of longitudes against latitudes.\nBecause of the large number of data points, use black pixel markers (use \\li{\"k,\"} as the third argument to \\li{plt.plot()}).\nLabel both axes.\n\\\\\n(Hint: Use \\li{plt.axis(\"equal\")} to fix the axis ratio on the scatter plot).\n\n\\item A histogram of the hours of the day, with one bin per hour.\nSet the limits of the $x$-axis appropriately.\nLabel the $x$-axis.\n\\end{enumerate}\n\\end{problem}\n\n% Other kinds of plots for 1-dimensional data includes bar plots, box plots, and others.\n% See Appendix \\ref{mpltables} for examples and syntax.\n\n\\subsection*{Visualizing 3-D Surfaces} % --------------------------------------\n\nTo plot a function $f: \\mathbb{R}^2 \\rightarrow \\mathbb{R}$, we must choose and construct a 2-dimensional domain, then calculate the function at each point of that domain.\nThe standard tool for creating a 2-dimensional domain in the Cartesian plane is \\li{np.meshgrid()}.\nGiven two 1-dimensional coordinate arrays, \\li{np.meshgrid()} creates two corresponding coordinate matrices.\n%\n\\begin{figure}[H] % np.meshgrid() visual demonstration.\n\\begin{tikzpicture}[>=stealth', shorten <= .1cm,shorten >=.1cm, dot/.style=\n {circle,fill=black,minimum size=3pt,inner sep=0pt, outer sep=-1pt} ]\n\n\\foreach \\x/\\y in {0/0, 0/2, 0/4, 2/0, 2/2, 2/4, 4/0, 4/2, 4/4}\n \\node[draw, dot]at(\\x,\\y){};\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*2-.5, \\y*2+.3){(\\x,\\y)};\n\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*.75+7, \\y*.75+.1){\\y};\n\\foreach \\x/\\y in {0/0, 0/1, 0/2, 1/0, 1/1, 1/2, 2/0, 2/1, 2/2}\n \\node[draw=none]at(\\x*.75+7, \\y*-.75+3.9){\\x};\n\n\\draw[-, thick](6.7,-.25)--(6.7,1.95);\n\\draw[-, thick](8.8,-.25)--(8.8,1.95);\n\\draw[-, thick](6.7,2.05)--(6.7,4.25);\n\\draw[-, thick](8.8,2.05)--(8.8,4.25);\n\\draw[-, thick](8.8,4.14)--(8.7,4.14);\n\\draw[-, thick](8.8,2.16)--(8.7,2.16);\n\\draw[-, thick](6.7,4.14)--(6.8,4.14);\n\\draw[-, thick](6.7,2.16)--(6.8,2.16);\n\\draw[-, thick](8.8,1.84)--(8.7,1.84);\n\\draw[-, thick](8.8,-.135)--(8.7,-.135);\n\\draw[-, thick](6.8,1.84)--(6.7,1.84);\n\\draw[-, thick](6.8,-.135)--(6.7,-.135);\n\n\\node[draw=none](X)at(6.3,.9){\\texttt{Y}=};\n\\node[draw=none](y)at(6.3,3.15){\\texttt{X}=};\n\n\\node[draw=none](point1)at(-.3, -.6){\\texttt{x}=\\big[0,};\n\\node[draw=none, node distance=2.35cm](point2)\n [right of=point1]{1,};\n\\node[draw=none, node distance=2cm](point3)\n [right of=point2]{2\\big]};\n\\node[draw=none, rotate=270](point4)at(4.6,4.25)\n {\\texttt{y}=\\big[2,};\n\\node[draw=none, rotate=270, node distance=2.35cm](point5)\n [right of=point4]{1,};\n\\node[draw=none, rotate=270, node distance=2cm](point6)\n [right of=point5]{0\\big]};\n\\end{tikzpicture}\n\\caption{\\li{np.meshgrid(x, y)}, returns the arrays \\li{X} and \\li{Y}.\nThe returned arrays give the $x$- and $y$-coordinates of the points in the grid formed by \\li{x} and \\li{y}.\nSpecifically, the arrays \\li{X} and \\li{Y} satisfy \\li{(X[i,j], Y[i,j]) = (x[i],y[j])}.}\n\\label{fig:meshgrid}\n\\end{figure}\n\nWith a 2-dimensional domain, we usually visualize $f$ with two kinds of plots.\n\n\\begin{itemize}\n\\item A \\emph{heat map} assigns a color to each entry in the matrix, producing a 2-dimensional picture describing a 3-dimensional shape.\nDarker colors typically correspond to lower values while lighter colors typically correspond to higher values.\n\nUse \\li{plt.pcolormesh()} to create a heat map.\n\n\\item A \\emph{contour map} draws several \\emph{level curves} of $f$.\nA level curve corresponding to the constant $c$ is the collection of points $\\left\\{(x,y)\\mid c = f(x,y)\\right\\}$.\nColoring the space between the level curves produces a discretized version of a heat map.\nIncluding more and more level curves makes a filled contour plot look more and more like the complete, blended heat map.\n\nUse \\li{plt.contour()} to create a contour plot and \\li{plt.contourf()} to create a filled contour plot.\nSpecify either the number of level curves to draw, or a list of constants corresponding to specific level curves.\n\\end{itemize}\n\nThese three functions all receive the keyword argument \\li{cmap} to specify a color scheme (some of the better schemes are \\li{\"viridis\"}, \\li{\"magma\"}, and \\li{\"Spectral\"}).\nSee \\url{http://matplotlib.org/examples/color/colormaps_reference.html} for the list of all Matplotlib color schemes.\n\nFinally, to see how the colors in these plots relate to the values of the function, use \\li{plt.colorbar()} to draw the color scale beside the plot.\n\n\\begin{lstlisting}\n# Create a 2-D domain with np.meshgrid().\n>>> x = np.linspace(-np.pi, np.pi, 100)\n>>> y = x.copy()\n>>> X, Y = np.meshgrid(x, y)\n\n# Calculate z = f(x,y) = sin(x)sin(y) using the meshgrid coordinates.\n>>> Z = np.sin(X) * np.sin(Y)\n\n# Plot the heat map of f over the 2-D domain.\n>>> plt.subplot(131)\n>>> plt.pcolormesh(X, Y, Z, cmap=\"viridis\")\n>>> plt.colorbar()\n>>> plt.xlim(-np.pi, np.pi)\n>>> plt.ylim(-np.pi, np.pi)\n\n# Plot a contour map of f with 10 level curves.\n>>> plt.subplot(132)\n>>> plt.contour(X, Y, Z, 10, cmap=\"Spectral\")\n>>> plt.colorbar()\n\n# Plot a filled contour map, specifying the level curves.\n>>> plt.subplot(133)\n>>> plt.contourf(X, Y, Z, [-1, -.8, -.5, 0, .5, .8, 1], cmap=\"magma\")\n>>> plt.colorbar()\n\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H] % heat map and contour plots.\n\\captionsetup[subfigure]{justification=centering}\n\\centering\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/heatmap.png}\n\\end{subfigure}%\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/contour.pdf}\n\\end{subfigure}%\n\\begin{subfigure}{.33\\textwidth}\n \\centering\n \\includegraphics[width=\\linewidth]{figures/contourf.pdf}\n\\end{subfigure}\n\\end{figure}\n\n\\begin{problem} % Heat map / contour plot of a function f:R2->R.\n\\label{prob:heatmap}\nWrite a function to plot $f(x,y) = \\frac{\\sin(x)\\sin(y)}{xy}$ on the domain $[-2\\pi,2\\pi] \\times [-2\\pi,2\\pi]$.\n\n\\begin{enumerate}\n\\item Create 2 subplots: one with a heat map of $f$, and one with a contour map of $f$.\nChoose an appropriate number of level curves, or specify the curves yourself.\n\\item Set the limits of each subplot to $[-2\\pi,2\\pi] \\times [-2\\pi,2\\pi]$.\n\\item Choose a non-default color scheme.\n\\item Include the color scale bar for each subplot.\n\\end{enumerate}\n\\end{problem}\n\n\\begin{info} % Note about plt.imshow().\nImages are usually stored as either a 2-dimensional array (for black-and-white pictures) or a 3-dimensional array (a stack of 2-dimensional arrays, one for each RGB value).\nThis kind of data does not require a domain, and is easily visualized with \\li{plt.imshow()}.\n\\end{info}\n\n\\newpage\n\n\\section*{Additional Material} % ==============================================\n\n\\subsection*{3-D Plotting} % --------------------------------------------------\n\nMatplotlib can also be used to plot 3-dimensional surfaces.\nThe following code produces the surface corresponding to $f(x,y) = \\sin(x)\\sin(y)$.\n\n\\begin{lstlisting}\n# Create the domain and calculate the range like usual.\n>>> x = np.linspace(-np.pi, np.pi, 200)\n>>> y = np.copy(x)\n>>> X, Y = np.meshgrid(x, y)\n>>> Z = np.sin(X)*np.sin(Y)\n\n# Draw the corresponding 3-D plot using some extra tools.\n>>> from mpl_toolkits.mplot3d import Axes3D\n>>> fig = plt.figure()\n>>> ax = fig.gca(projection='3d')\n>>> ax.plot_surface(X, Y, Z)\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n \\includegraphics[width=.7\\textwidth]{figures/surface_plot.pdf}\n\\end{figure}\n\n\\subsection*{Animations} % ----------------------------------------------------\n\nLines and other graphs can be altered dynamically to produce animations.\nFollow these steps to create a Matplotlib animation:\n%\n\\begin{enumerate}\n \\item Calculate all data that is needed for the animation.\n \\item Define a figure explicitly with \\li{plt.figure()} and set its window boundaries.\n \\item Draw empty objects that can be altered dynamically.\n \\item Define a function to update the drawing objects.\n \\item Use \\li{matplotlib.animation.FuncAnimation()}.\n\\end{enumerate}\n\nThe submodule \\li{matplotlib.animation} contains the tools putting together and managing animations.\nThe function \\li{matplotlib.animation.FuncAnimation()} accepts the figure to animate, the function that updates the figure, the number of frames to show before repeating, and how fast to run the animation (lower numbers mean faster animations).\n\n\\begin{lstlisting}\nfrom matplotlib.animation import FuncAnimation\n\ndef sine_animation():\n # Calculate the data to be animated.\n x = np.linspace(0, 2*np.pi, 200)[:-1]\n y = np.sin(x)\n\n # Create a figure and set its window boundaries.\n fig = plt.figure()\n plt.xlim(0, 2*np.pi)\n plt.ylim(-1.2, 1.2)\n\n # Draw an empty line. The comma after 'drawing' is crucial.\n drawing, = plt.plot([],[])\n\n # Define a function that updates the line data.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n return drawing, # Note the comma!\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10)\n plt.show()\n\\end{lstlisting}\n\nTry using the following function in place of \\li{update()}.\nCan you explain why this animation is different from the original?\n\n\\begin{lstlisting}\ndef wave(index):\n drawing.set_data(x, np.roll(y, index))\n return drawing,\n\\end{lstlisting}\n\nTo animate multiple objects at once, define the objects separately and make sure the update function returns both objects.\n\n\\begin{lstlisting}\ndef sine_cosine_animation():\n x = np.linspace(0, 2*np.pi, 200)[:-1]\n y1, y2 = np.sin(x), np.cos(x)\n\n fig = plt.figure()\n plt.xlim(0, 2*np.pi)\n plt.ylim(-1.2, 1.2)\n\n sin_drawing, = plt.plot([],[])\n cos_drawing, = plt.plot([],[])\n\n def update(index):\n sin_drawing.set_data(x[:index], y1[:index])\n cos_drawing.set_data(x[:index], y2[:index])\n return sin_drawing, cos_drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10)\n plt.show()\n\\end{lstlisting}\n\nAnimations are very useful for describing parametrized curves, as the ``speed'' of the curve is displayed.\nThe code below animates the rose curve, parametrized by the angle $\\theta \\in [0, 2\\pi]$, given by the following equations:\n%\n\\[\\begin{array}{ccc}\nx(\\theta) = \\cos(\\theta)\\cos(6\\theta), && y(\\theta) = \\sin(\\theta)\\cos(6\\theta)\n\\end{array}\\]\n\n\\begin{lstlisting}\ndef rose_animation():\n # Calculate the parametrized data.\n theta = np.linspace(0, 2*np.pi, 200)\n x = np.cos(theta)*np.cos(6*theta)\n y = np.sin(theta)*np.cos(6*theta)\n\n fig = plt.figure()\n plt.xlim(-1.2, 1.2)\n plt.ylim(-1.2, 1.2)\n plt.gca().set_aspect(\"equal\") # Make the figure exactly square.\n\n drawing, = plt.plot([],[])\n\n # Define a function that updates the line data.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n return drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10, repeat=False)\n plt.show() # repeat=False freezes the animation at the end.\n\\end{lstlisting}\n\nAnimations can also be 3-dimensional.\nThe only major difference is an extra operation to set the 3-dimensional component of the drawn object.\nThe code below animates the space curve parametrized by the following equations:\n%\n\\[\\begin{array}{ccccc}\nx(\\theta) = \\cos(\\theta)\\cos(6\\theta), &&\ny(\\theta) = \\sin(\\theta)\\cos(6\\theta), &&\nz(\\theta) = \\frac{\\theta}{10}\n\\end{array}\\]\n\n\\begin{lstlisting}\ndef rose_animation_3D():\n theta = np.linspace(0, 2*np.pi, 200)\n x = np.cos(theta) * np.cos(6*theta)\n y = np.sin(theta) * np.cos(6*theta)\n z = theta / 10\n\n fig = plt.figure()\n ax = fig.gca(projection='3d') # Make the figure 3-D.\n ax.set_xlim3d(-1.2, 1.2) # Use ax instead of plt.\n ax.set_ylim3d(-1.2, 1.2)\n ax.set_aspect(\"equal\")\n\n drawing, = ax.plot([],[],[]) # Provide 3 empty lists.\n\n # Update the first 2 dimensions like usual, then update the 3-D component.\n def update(index):\n drawing.set_data(x[:index], y[:index])\n drawing.set_3d_properties(z[:index])\n return drawing,\n\n a = FuncAnimation(fig, update, frames=len(x), interval=10, repeat=False)\n plt.show()\n\\end{lstlisting}\n\n\\begin{comment} % TODO: An ORIGINAL example of using widgets\n\\subsection*{Interactive Plots} % ---------------------------------------------\n\nMatplotlib plots can be made interactive by adding \\emph{widgets}.\nConsider the following example, TAKEN FROM THE MATPLOTLIB DOCS BASICALLY AHHH\n\n\\begin{lstlisting}\n>>> from matplotlib import widgets as wg\n\n>>> ax = plt.subplot(111)\n>>> plt.subplots_adjust(bottom=.25) # Make some space for a slider bar.\n>>> t = np.arange(0., 1., .001)\n>>> a0 = 5.\n>>> f0 = 3.\n>>> s = a0 * np.sin(2 * np.pi * f0 * t)\n>>> l = plt.plot(t, s)[0]\n>>> plt.axis([0, 1, -10, 10])\n>>> axfreq = plt.axes([.25, .05, .65, .03])\n>>> axamp = plt.axes([.25, .1, .65, .03])\n\n# Make some slider bars.\n>>> sfreq = wg.Slider(axfreq, 'Freq', .1, 30., valinit=f0)\n>>> samp = wg.Slider(axamp, 'Amp', .1, 10., valinit=a0)\n>>> def update(val): # Function for updating the plot.\n... amp = samp.val # Read from one slider.\n... freq = sfreq.val # Read from the other slider.\n... l.set_ydata(amp * np.sin(2 * np.pi * freq * t))\n... plt.draw() # Refresh the plot.\n>>> sfreq.on_changed(update) # Connect the sliders to update().\n>>> samp.on_changed(update)\n>>> plt.show()\n\\end{lstlisting}\n\n\\begin{figure}[H]\n\\includegraphics[width=.7\\textwidth]{figures/interactive_plot.pdf}\n\\end{figure}\n\\end{comment}\n\n% =============================================================================\n% =============================================================================\n% Stuff to move ===============================================================\n% =============================================================================\n% =============================================================================\n\n\\begin{comment}\n\\begin{info} % IPython Notebook inline plotting (move to notebook intro)\nIf you are executing these Matplotlib commands in an IPython shell, executing the \\li{plt.show()} method will open a new window with the plot.\nIf you are using IPython Notebook, you have the option to display the plots within your notebook.\nYou may opt into this feature by running \\li{\\%matplotlib inline} or \\li{\\%matplotlib notebook} in your IPython Notebook.\nThe \\li{inline} option shows the plot, whereas the \\li{notebook} option shows the plot and provides controls to interact with the plot.\nAdditionally, when using this option, the plot is displayed after running the \\li{plt.plot()} command; the \\li{plt.show()} command is not necessary.\n\\end{info}\n\\end{comment}\n\n", "meta": {"hexsha": "07b3d3222601d93992647ccafe217674c455095a", "size": 32031, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Introduction/PlottingIntro/PlottingIntro.tex", "max_stars_repo_name": "joshualy/numerical_computing", "max_stars_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_stars_repo_licenses": ["CC-BY-3.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Introduction/PlottingIntro/PlottingIntro.tex", "max_issues_repo_name": "joshualy/numerical_computing", "max_issues_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_issues_repo_licenses": ["CC-BY-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Introduction/PlottingIntro/PlottingIntro.tex", "max_forks_repo_name": "joshualy/numerical_computing", "max_forks_repo_head_hexsha": "9f474e36fe85ae663bd20e2f2d06265d1f095173", "max_forks_repo_licenses": ["CC-BY-3.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-05T14:45:03.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-05T14:45:03.000Z", "avg_line_length": 41.3837209302, "max_line_length": 269, "alphanum_fraction": 0.6690393681, "num_tokens": 9195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802395624259, "lm_q2_score": 0.9184802412359966, "lm_q1q2_score": 0.8436059520037928}} {"text": "\\subsection{Green's Theorem for Circulation}\r\n\\begin{theorem}[Green's Theorem for Circulation]\r\n\tLet $C$ be a closed, counter-clockwise oriented curve in $\\mathbb{R}^2$. For any differentiable vector field,\r\n\t\\begin{equation*}\r\n\t\t\\vec{F}(x,y) = \\langle Q(x,y), R(x,y) \\rangle \\text{, } \\oint\\limits_{C}{R\\mathrm{d}x + Q\\mathrm{d}y} = \\iint\\limits_{D}{\\left(\\frac{\\partial Q}{\\partial x} - \\frac{\\partial R}{\\partial y}\\right)\\mathrm{d}x\\mathrm{d}y}\r\n\t\\end{equation*}\r\n\twhere $D$ is the interior of $C$.\r\n\\end{theorem}\r\n\\noindent\r\nOr, in more modern notation,\r\n\\begin{equation*}\r\n\t\\oint\\limits_{C}{\\vec{F} \\cdot \\mathrm{d}\\vec{r}} = \\iint\\limits_{D}{\\nabla\\times\\vec{F}\\mathrm{d}A}\r\n\\end{equation*}\r\n\r\n[INSERT IMAGE]\r\n\r\n\\noindent\r\nThis is saying that summing up the interior of the derivative is the to summing up the boundary of the function, very similar to the FTC.\\\\\r\nOne can think of this in a physical sense as saying that the work done by the vector field in moving a particle counter-clockwise on $C$ is equal to the rotation (curl) inside of $C$ ($D$).\\\\\r\nThis theorem also relates the idea of path independence and curl of a conservative vector field that we proved the 2D case for. The left side shows path independence and will be 0 for conservative vector fields, and the right side shows curl, which will also be 0 for conservative vector fields.\r\n\r\n\\begin{proof}[Partial Proof]\r\n\tWe will prove the 2D case, but the underlying argument is easily generalized.\r\n\t\\begin{equation*}\r\n\t\t\\oint\\limits_{C}{\\vec{F} \\cdot \\mathrm{d}\\vec{r}} = \\oint\\limits_{c}{\\langle P(x,y), 0 \\rangle \\cdot \\mathrm{d}\\vec{r}} + \\oint\\limits_{C}{\\langle 0, Q(x,y) \\rangle \\cdot \\mathrm{d}\\vec{r}}\r\n\t\\end{equation*}\r\n\tIf $D$ is convex, we an break $C$ into 2 curves on the same interval, $C_1$ and $C_2$ such that $C_1 : \\vec{r} \\langle x, h_1(x) \\rangle$ and $C_2 : \\vec{r} \\langle x, h_2(x) \\rangle$, where $x \\in [a,b]$.\r\n\t\r\n\t[INSERT IMAGE]\r\n\t\r\n\t\\begin{equation*}\r\n\t\t= \\int_{a}^{b}{P(x,h_1(x))\\mathrm{d}x} - \\int_{a}^{b}{P(x,h_2(x))\\mathrm{d}x}\r\n\t\\end{equation*} \\begin{equation*}\r\n\t\t= -\\int_{a}^{b}{P(x,h_2(x)) - P(x,h_1(x))\\mathrm{d}x}\r\n\t\\end{equation*} \\begin{equation*}\r\n\t\t= -\\int_{a}^{b}{P(x,y)\\rvert_{y=h_1(x)}^{y=h_2(x)}\\mathrm{d}x}\r\n\t\\end{equation*} \\begin{equation*}\r\n\t\t= -\\int_{a}^{b}{\\int_{h_1(x)}^{h_2(x)}{\\frac{\\partial P}{\\partial y}\\mathrm{d}y}\\mathrm{d}x}\r\n\t\\end{equation*} \\begin{equation*}\r\n\t\t= -\\iint\\limits_{D}{\\frac{\\partial P}{\\partial y}\\mathrm{d}A} + \\iint\\limits_{D}{\\frac{\\partial Q}{\\partial x}\\mathrm{d}A}\r\n\t\\end{equation*} \\begin{equation*}\r\n\t\t= \\iint\\limits_{D}{\\nabla \\times \\vec{F}\\mathrm{d}A}\r\n\t\\end{equation*}\r\n\\end{proof}\r\n\r\n\\noindent\r\nFor example, let's use Green's Theorem for Circulation to compute $\\oint\\limits_{C}{\\vec{F} \\cdot \\mathrm{d}\\vec{r}}$ where $\\vec{F} = \\langle x^2, xy + x^2 \\rangle$ and $C$ is the unit circle.\r\n\\begin{equation*}\r\n\t\\oint\\limits_{C}{\\vec{F} \\cdot \\mathrm{d}\\vec{r}} = \\iint\\limits_{D}{\\nabla \\times \\vec{F}\\mathrm{d}A}\t\r\n\\end{equation*}\r\n\\begin{equation*}\r\n\t\\nabla \\times \\vec{F} = y+2x\t\r\n\\end{equation*}\r\nSince $C$ is the unit circle, we'll evaluate the integral using polar coordinates. So \r\n\\begin{equation*}\r\n\t\\mathrm{d}A = r\\mathrm{d}r\\mathrm{d}\\theta\t\r\n\\end{equation*}\r\n\\begin{align*}\r\n\t\\iint\\limits_{D}{\\nabla \\times \\vec{F}\\mathrm{d}A} &= \\int_{0}^{2\\pi}{\\int_{0}^{1}{(r\\sin{\\theta} + 2r\\cos{\\theta})r\\mathrm{d}r}\\mathrm{d}\\theta} \\\\\r\n\t&= \\int_{0}^{2\\pi}{\\left(\\frac{\\sin{\\theta}}{3} + \\frac{2\\cos{\\theta}}{3}\\right)\\mathrm{d}\\theta} = 0\r\n\\end{align*}\r\nNote that although this particular circulation is 0, we know that the vector field is not conservative because the curl is not 0.\r\n\r\n\\input{./vectorAnalysis/areaClosedRegion}", "meta": {"hexsha": "a32e92223cb1f5f68da3865748113d3a004c8ae9", "size": 3696, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "multiCalc/vectorAnalysis/greensTheoremCirculation.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "multiCalc/vectorAnalysis/greensTheoremCirculation.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "multiCalc/vectorAnalysis/greensTheoremCirculation.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.75, "max_line_length": 296, "alphanum_fraction": 0.663961039, "num_tokens": 1382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505428129514, "lm_q2_score": 0.9324533074525657, "lm_q1q2_score": 0.8435443907346954}} {"text": "\\subsection{Eigenvalues \\& Eigenvectors}\r\n\\begin{definition}\r\n\tLet $A$ be an $n \\times n$ matrix. A scalar $\\lambda$ and a vector $\\vec{v}$ are an eigenvalue and eigenvector of $A$ if\r\n\t\\begin{equation*}\r\n\t\tA\\vec{v} = \\lambda\\vec{v}.\r\n\t\\end{equation*}\r\n\\end{definition}\r\n\\noindent\r\nWe call $p(\\lambda) = \\det{(A - \\lambda I)}$ the characteristic polynomial of $A$. The eigenvalues for $A$ are the solutions to the equation\r\n\\begin{equation*}\r\n\tp(\\lambda) = \\det{(A - \\lambda I)} = 0.\r\n\\end{equation*}\r\nOnce we have an eigenvalue, we can find the basis vectors for the corresponding eigenspace by solving the equation\r\n\\begin{equation*}\r\n\t\\left( A - \\lambda I \\right)\\vec{v} = \\vec{0}.\r\n\\end{equation*}\r\nThe basis vectors of the eigenspace for $A$ are the union of the basis vectors of each eigenspace corresponding to each eigenvalue.\r\n\r\n\\begin{example}\r\n\tFind the eigenvalues and eigenvectors of\r\n\t\\begin{equation*}\r\n\t\tA = \\begin{bmatrix}\r\n\t\t\t2 & 1 & 3 \\\\\r\n\t\t\t1 & 2 & 3 \\\\\r\n\t\t\t3 & 3 & 20\r\n\t\t\\end{bmatrix}.\r\n\t\\end{equation*}\r\n\\end{example}\r\n\\begin{equation*}\r\n\tp(\\lambda) = \\begin{array}{|ccc|}\r\n\t\t2-\\lambda & 1 & 3 \\\\\r\n\t\t1 & 2-\\lambda & 3 \\\\\r\n\t\t3 & 3 & 20-\\lambda\r\n\t\\end{array} = \r\n\t-(\\lambda - 21)(\\lambda - 2)(\\lambda - 1) = 0 \\implies \\lambda = 1 \\text{, } 2 \\text{, and } 21.\r\n\\end{equation*}\r\nWhen $\\lambda = 1$,\r\n\\begin{equation*}\r\n\tA-\\lambda I = \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t2-1 & 1 & 3 & 0 \\\\\r\n\t\t1 & 2-1 & 3 & 0 \\\\\r\n\t\t3 & 3 & 20-1 & 0\r\n\t\\end{array} \r\n\t\\right] \\to \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t1 & 1 & 0 & 0 \\\\\r\n\t\t0 & 0 & 1 & 0 \\\\\r\n\t\t0 & 0 & 0 & 0\r\n\t\\end{array}\r\n\t\\right] \\implies \\vec{v_{1}} = t \\begin{bmatrix}\r\n\t\t-1 \\\\\r\n\t\t1 \\\\\r\n\t\t0\r\n\t\\end{bmatrix}.\r\n\\end{equation*}\r\nWhen $\\lambda = 2$,\r\n\\begin{equation*}\r\n\tA-\\lambda I = \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t2-2 & 1 & 3 & 0 \\\\\r\n\t\t1 & 2-2 & 3 & 0 \\\\\r\n\t\t3 & 3 & 20-2 & 0\r\n\t\\end{array} \r\n\t\\right] \\to \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t1 & 0 & 3 & 0 \\\\\r\n\t\t0 & 1 & 3 & 0 \\\\\r\n\t\t0 & 0 & 0 & 0\r\n\t\\end{array}\r\n\t\\right] \\implies \\vec{v_{2}} = \\begin{bmatrix}\r\n\t\t-3 \\\\\r\n\t\t-3 \\\\\r\n\t\t1\r\n\t\\end{bmatrix}.\r\n\\end{equation*}\r\nWhen $\\lambda = 21$,\r\n\\begin{equation*}\r\n\tA-\\lambda I = \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t2-21 & 1 & 3 & 0 \\\\\r\n\t\t1 & 2-21 & 3 & 0 \\\\\r\n\t\t3 & 3 & 20-21 & 0\r\n\t\\end{array} \r\n\t\\right] \\to \\left[\r\n\t\\begin{array}{ccc|c}\r\n\t\t1 & 0 & -1/6 & 0 \\\\\r\n\t\t0 & 1 & -1/6 & 0 \\\\\r\n\t\t0 & 0 & 0 & 0\r\n\t\\end{array}\r\n\t\\right] \\implies \\vec{v_{21}} = \\begin{bmatrix}\r\n\t\t1 \\\\\r\n\t\t1 \\\\\r\n\t\t6\r\n\t\\end{bmatrix}.\r\n\\end{equation*}\r\nBonus: $A$'s diagonalization is\r\n\\begin{equation*}\r\n\tA = PDP^{-1} \\implies \\begin{bmatrix}\r\n\t\t2 & 1 & 3 \\\\\r\n\t\t1 & 2 & 3 \\\\\r\n\t\t3 & 3 & 20\r\n\t\\end{bmatrix} = \\begin{bmatrix}\r\n\t\t-1 & -3 & 1 \\\\\r\n\t\t1 & -3 & 1 \\\\\r\n\t\t0 & 1 & 6\r\n\t\\end{bmatrix} \\begin{bmatrix}\r\n\t\t1 & 0 & 0 \\\\\r\n\t\t0 & 2 & 0 \\\\\r\n\t\t0 & 0 & 21\r\n\t\\end{bmatrix} \\begin{bmatrix}\r\n\t\t-1/2 & 1/2 & 0 \\\\\r\n\t\t-3/19 & -3/19 & 1/19 \\\\\r\n\t\t1/38 & 1/38 & 3/19\r\n\t\\end{bmatrix}.\r\n\\end{equation*}", "meta": {"hexsha": "5517281295f44e5d0db5beb219a28cd139a1f24b", "size": 2899, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "common/vectorsMatrices/eigenvaluesEigenvectors.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "common/vectorsMatrices/eigenvaluesEigenvectors.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "common/vectorsMatrices/eigenvaluesEigenvectors.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 24.9913793103, "max_line_length": 141, "alphanum_fraction": 0.5367368058, "num_tokens": 1328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.93812402119614, "lm_q2_score": 0.8991213772699435, "lm_q1q2_score": 0.8434873619878911}} {"text": "\n\\subsection{Expectation of OLS estimators}\n\n\\subsubsection{Expectation in terms of observables}\n\nWe have: \\(\\hat{\\theta }=(X^TX)^{-1}X^Ty\\)\n\nLet’s take the expectation.\n\n\\(E[\\hat{\\theta }]=E[(X^TX)^{-1}X^Ty]\\)\n\n\\subsubsection{Expectation in terms of errors}\n\nLet’s model \\(y\\) as a function of \\(X\\). As we place no restrictions on the error terms, this is not as assumption.\n\n\\(y=X\\theta +\\epsilon\\). \n\n\\(E[\\hat{\\theta }]=E[(X^TX)^{-1}X^T(X\\theta +\\epsilon)]\\)\n\n\\(E[\\hat{\\theta }]=E[(X^TX)^{-1}X^TX\\theta ]+E[(X^TX)^{-1}X^T \\epsilon)]\\)\n\n\\(E[\\hat{\\theta }]=\\theta +E[(X^TX)^{-1}X^T \\epsilon)]\\)\n\n\\(E[\\hat{\\theta }]=\\theta +E[(X^TX)^{-1}X^T]E[ \\epsilon]+cov [(X^TX)^{-1}X^T ,\\epsilon]\\)\n\n\\subsubsection{The Gauss-Markov: Expected error is \\(0\\)}\n\n\\(E[\\epsilon =0]\\)\n\nThis means that:\n\n\\(E[\\hat{\\theta }]=\\theta + cov [(X^TX)^{-1}X^T ,\\epsilon]\\)\n\n\\subsubsection{The Gauss-Markov: Errors and indepedent variables are uncorrelated}\n\nIf the error terms and \\(X\\) are uncorrelated then \\(E[\\epsilon|X]=0\\) and therefore:\n\n\\(E[\\hat{\\theta }]=\\theta\\)\n\nSo this is an unbiased estimator, so long as the condition holds.\n\n\n", "meta": {"hexsha": "b62fd4edc23a86c4a7cc52eaaa9d51bc240add0d", "size": 1117, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/statistics/olsInference/01-01-moments.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/statistics/olsInference/01-01-moments.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/statistics/olsInference/01-01-moments.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.976744186, "max_line_length": 116, "alphanum_fraction": 0.6311548791, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240108164656, "lm_q2_score": 0.8991213745668095, "lm_q1q2_score": 0.843487350119429}} {"text": "\n\\subsection{Concave and convex functions}\n\n\\subsubsection{Convex functions}\n\nA convex function is one where:\n\n\\(\\forall x_1, x_2\\in \\mathbb{R} \\forall t \\in [0,1] [f(tx_1+(1-t)x_2 \\le tf(x_1)+(1-t)f(x_2)]\\)\n\nThat is, for any two points of a function, a line between the two points is above the curve.\n\nA function is strictly convex if the line between two points is strictly above the curve:\n\n\\(\\forall x_1, x_2\\in \\mathbb{R} \\forall t \\in (0,1) [f(tx_1+(1-t)x_2 < tf(x_1)+(1-t)f(x_2)]\\)\n\nAn example is \\(y=x^2\\).\n\n\\subsubsection{Concave functions}\n\nA concave function is an upside down convex function. The line between two points is below the curve.\n\n\\(\\forall x_1, x_2\\in \\mathbb{R} \\forall t \\in [0,1] [f(tx_1+(1-t)x_2 \\ge tf(x_1)+(1-t)f(x_2)]\\)\n\nA function is strictly concave if the line between two points is strictly below the curve:\n\n\\(\\forall x_1, x_2\\in \\mathbb{R} \\forall t \\in (0,1) [f(tx_1+(1-t)x_2 > tf(x_1)+(1-t)f(x_2)]\\)\n\nAn example is \\(y=-x^2\\).\n\n\\subsubsection{Affine functions}\n\nIf a function is both concave and convex, then the line between two points must be the function itself. This means the function is an affine function.\n\n\\(y=cx\\)\n\n", "meta": {"hexsha": "2471cdc542593afb5af04a430e856cca9ea6583e", "size": 1163, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/propertiesFunctions/01-05-analysisCon.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/propertiesFunctions/01-05-analysisCon.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/propertiesFunctions/01-05-analysisCon.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3055555556, "max_line_length": 150, "alphanum_fraction": 0.6990541702, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002789, "lm_q2_score": 0.9149009561531424, "lm_q1q2_score": 0.8434671701700166}} {"text": "\\subsection{Quotient Rule}\r\n\\begin{lemma}\r\n\tLet $f$ and $g$ be differentiable functions where $g \\neq 0$. Then\r\n\t\\begin{equation}\r\n\t\t\\left(\\frac{f}{g}\\right)^\\prime = \\frac{gf^\\prime - fg^\\prime}{g^2}.\r\n\t\\end{equation}\r\n\\end{lemma}\r\n\\begin{proof}\r\n\tUsing the definition of the derivative and limit properties,\r\n\t\\begin{align*}\r\n\t\t\\left(\\frac{f}{g}\\right)^\\prime &= \\lim_{h\\to 0}{\\frac{\\frac{f(x+h)}{g(x+h)} - \\frac{f(x)}{g(x)}}{h}} \\\\\r\n\t\t&= \\lim_{h\\to 0}{\\frac{1}{h}\\frac{f(x+h)g(x) - f(x)g(x+h)}{g(x+h)g(x)}} \\\\\r\n\t\t&= \\lim_{h\\to 0}{\\frac{1}{h}\\hspace{3pt}\\frac{f(x+h)g(x) - f(x)g(x) + f(x)g(x) - f(x)g(x+h)}{g(x+h)g(x)}} \\\\\r\n\t\t&= \\lim_{h \\to 0}{\\frac{1}{g(x+h)g(x)}\\hspace{3pt}\\frac{f(x+h)g(x)-f(x)g(x)+f(x)g(x)-f(x)g(x+h)}{h}} \\\\\r\n\t\t&= \\lim_{h \\to 0}{\\frac{1}{g(x+h)g(x)}\\left(\\frac{f(x+h)g(x)-f(x)g(x)}{h}+\\frac{f(x)g(x)-f(x)g(x+h)}{h}\\right)} \\\\\r\n\t\t&= \\lim_{h \\to 0}{\\frac{1}{g(x+h)g(x)}} \\left(g(x)\\lim_{h \\to 0}{\\frac{f(x+h)-f(x)}{h}} - f(x)\\lim_{h\\to 0}{\\frac{g(x+h)-g(x)}{h}}\\right) \\\\\r\n\t\t&= \\frac{1}{g^2(x)}\\left(g(x)f^\\prime(x) - f(x)g^\\prime(x)\\right) \\\\\r\n\t\t&= \\frac{gf^\\prime - fg^\\prime}{g^2}.\r\n\t\\end{align*}\r\n\\end{proof}\r\n\r\n\\begin{example}\r\n\tGiven that the derivative of $\\sin{(x)}$ is $\\cos{(x)}$, find the derivative of $\\frac{\\sin{(x)}}{x^2}$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tApplying the quotient and power rules,\r\n\t\\begin{equation*}\r\n\t\tf^\\prime(x) = \\frac{x^2\\cos{(x) - 2x\\sin{(x)}}}{x^4} = \\frac{x\\cos{(x)}-2\\sin{(x)}}{x^3}.\r\n\t\\end{equation*}\r\n\\end{answer}", "meta": {"hexsha": "c287607a16110db91bed12495b94335f304201e5", "size": 1477, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/derivatives/derivative_rules/quotient_rule.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/derivatives/derivative_rules/quotient_rule.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/derivatives/derivative_rules/quotient_rule.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 49.2333333333, "max_line_length": 143, "alphanum_fraction": 0.5423155044, "num_tokens": 696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768572945971, "lm_q2_score": 0.8933094145755219, "lm_q1q2_score": 0.8434420756455927}} {"text": "\\subsection{Complex numbers}\nWhen Eigenmath starts up, it defines the symbol $i$ as $i=\\sqrt{-1}$.\nOther than that, there is nothing special about $i$.\nIt is just a regular symbol that can be redefined and used for some other purpose if need be.\n\nComplex quantities can be entered in either rectangular or polar form.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\na+i*b\n\\end{Verbatim}\n\n$\\displaystyle a+ib$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nexp(i*pi/3)\n\\end{Verbatim}\n\n$\\displaystyle \\exp(\\frac{1}{3}i\\pi)$\n\nConverting to rectangular or polar coordinates causes\nsimplification of mixed forms.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nA = 1+i\nB = sqrt(2)*exp(i*pi/4)\nA-B\n\\end{Verbatim}\n\n$1+i-2^{1/2}\\exp(\\frac{1}{4}i\\pi)$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nrect(last)\n\\end{Verbatim}\n\n$\\displaystyle 0$\n\nRectangular complex quantities, when raised to a power, are multiplied out.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\n(a+i*b)^2\n\\end{Verbatim}\n\n$\\displaystyle a^2-b^2+2iab$\n\nWhen $a$ and $b$ are numerical and the power is negative, the evaluation is done as follows.\n$$i\n(a+ib)^{-n}\n=\\left[\\frac{a-ib}{(a+ib)(a-ib)}\\right]^n=\n\\left[\\frac{a-ib}{a^2+b^2}\\right]^n$$\nOf course, this causes $i$ to be removed from the denominator.\n%For $n=1$ we have\n%$${1\\over a+ib}={a-ib\\over a^2+b^2}$$\nHere are a few examples.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\n1/(2-i)\n\\end{Verbatim}\n\n$\\displaystyle \\frac{2}{5}+\\frac{1}{5}i$\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\n(-1+3i)/(2-i)\n\\end{Verbatim}\n\n$\\displaystyle -1+i$\n\nThe absolute value of a complex number returns its magnitude.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nabs(3+4*i)\n\\end{Verbatim}\n\n$\\displaystyle 5$\n\nSince symbols can have complex values, the absolute value\nof a symbolic expression is not computed.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nabs(a+b*i)\n\\end{Verbatim}\n\n$\\displaystyle {\\rm abs}(a+ib)$\n\nThe result is not $\\sqrt{a^2+b^2}$ because that would assume that\n$a$ and $b$ are real.\nFor example, suppose that $a=0$ and $b=i$.\nThen\n$$|a+ib|=|-1|=1$$\nand\n$$\\sqrt{a^2+b^2}=\\sqrt{-1}=i$$\nHence\n$$|a+ib|\\ne\\sqrt{a^2+b^2}\\quad\\hbox{for some $a,b\\in\\mathbb C$}$$\n\nThe $mag$ function can be used instead of $abs$.\nIt treats symbols like $a$ and $b$ as real.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nmag(a+b*i)\n\\end{Verbatim}\n\n$\\displaystyle (a^2+b^2)^{1/2}$\n\nThe imaginary unit can be changed from $i$ to $j$\nby defining $j=\\sqrt{-1}$.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nj = sqrt(-1)\nsqrt(-4)\n\\end{Verbatim}\n\n$\\displaystyle 2j$\n", "meta": {"hexsha": "2876ffb289f16d71d62806e7df5036033eb13401", "size": 2664, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/complex.tex", "max_stars_repo_name": "zhouxs1023/eigenmath", "max_stars_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/complex.tex", "max_issues_repo_name": "zhouxs1023/eigenmath", "max_issues_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/complex.tex", "max_forks_repo_name": "zhouxs1023/eigenmath", "max_forks_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.7857142857, "max_line_length": 93, "alphanum_fraction": 0.7012012012, "num_tokens": 909, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172673767973, "lm_q2_score": 0.8887588052782736, "lm_q1q2_score": 0.8433585768617264}} {"text": "\\section{Regression: OLS}\n\n\n\\formdesc{Form}\n\n\\begin{equation}\n\ty = \\beta_0 + \\beta_1 x\n\\end{equation}\n\ndescribes the true, unobserved model, while\n\n\\begin{equation}\n\t\\hat{y} = b_0 + b_1x\n\\end{equation}\n\ndescribes the estimated model. The estimate $\\hat{y}$ describes the average value around which subjects where $x = x_i$ will cluster.\n\\hformbar\n\n\n\n\\formdesc{Residuals}\n\n\\begin{equation}\n\te_i = y_i - \\hat{y}_i\n\\end{equation}\n\nis the residual of the $i$th observations $(x_i, y_i)$, the differences between the observed response $(y_i)$ and the prediction $\\hat{y}$\n\n\\hformbar\n\n\n\n\\formdesc{Correlation}\n\n\\begin{equation}\n\tr = \\frac{1}{n - 1} \\sum_{i=1}^n \\frac{x_i - \\bar{x}}{s_x} ~ \\frac{y_i - \\bar{y}}{s_y}\n\\end{equation}\n\ndescribes the strength of the linear relationship between two variables $x$ and $y$, where $0 \\leq r \\leq 1$, and $s$ is sample standard deviation\n\\hformbar\n\n\n\n\\formdesc{Least Squares Criterion}\n\n\\begin{equation}\n\t\\mathrm{arg\\,min} \\sum_{i=1}^n e_i^2 \\equiv e_1^2 + e_2^2 + \\ldots + e_n^2\n\\end{equation}\n\ndescribes the best fitting line, the \\textit{least squares line}, i.e., minimizes the sum of squared residuals. To calculate:\n\n\\begin{equation}\n\tb_1 = \\frac{s_y}{s_x} r\n\\end{equation}\n\nthen use the fact that the point $(\\bar{x}, \\bar{y})$ is on the least squares line to set $x_0 = \\bar{x}$ and $y_0 = \\bar{y}$ along with the slope $b_1$, solve for $x$ in:\n\n\\begin{equation}\n\ty - \\hat{y} = b_1 (x - \\hat{x})\n\\end{equation}\n\n\\subsection*{Assumptions}\n\n\\begin{enumerate}\n\t\\item \\textit{Linearity}. Data must show a linear trend\n\t\\item \\textit{Near normal residuals}\n\t\\item \\textit{Constant variability}. The variability of points around the least-squares line must be constant, e.g., the scale of $e$ cannot increase as $x$ increases producing a fanning pattern\n\t\\item \\textit{Independent observations}. \n\\end{enumerate}\n\n\\hformbar\n\n\n\n\\formdesc{$r^2$}\n\n\\begin{equation}\n\tr^2 = 1 - \\frac{ \\sum_{i=1}^n (y_i - \\hat{y}_i)^2 }{ \\sum_{i=1}^n (y_i - \\bar{y})^2 } = 1 - \\frac{SSE}{SST}\n\\end{equation}\n\n\\begin{itemize}\n\t\\item $SSE$ is summed squares of residuals:\n\t\\item $SSTO$ is total sum of squares\n\\end{itemize}\n\n\\hformbar\n\n\n\n\\formdesc{Regression: T-Test}\n\nTests to determine if null hypothesis $b_1 = 0$ is to be rejected\n\\hformbar\n\n\n\n\n\n\n\n\n\\newpage\n", "meta": {"hexsha": "9d105494dce86bff5005ade5569407975f28be16", "size": 2276, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/ols.tex", "max_stars_repo_name": "benhorvath/math_notes", "max_stars_repo_head_hexsha": "47979bc9cbe52e6ccb9deca7afe9ff1b240e05f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ols.tex", "max_issues_repo_name": "benhorvath/math_notes", "max_issues_repo_head_hexsha": "47979bc9cbe52e6ccb9deca7afe9ff1b240e05f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ols.tex", "max_forks_repo_name": "benhorvath/math_notes", "max_forks_repo_head_hexsha": "47979bc9cbe52e6ccb9deca7afe9ff1b240e05f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0970873786, "max_line_length": 195, "alphanum_fraction": 0.6924428822, "num_tokens": 796, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404057671714, "lm_q2_score": 0.9073122226137632, "lm_q1q2_score": 0.8432926403436501}} {"text": "%!TEX root = TTK4215-Summary.tex\n\\section{Preliminaries}\n\\subsection{Norms}\nWe say $x \\in \\mathcal{L}_p$ when $||x||_p$ exists.\n\\paragraph{General $p$-norm}\n\\begin{equation}\n\t||x||_p\n\t=\n\t\\left(\n\t\t\\int_{0}^{\\infty} |x(t)|^p \\dif t\n\t\\right)\n\t^{1/p}\n\\end{equation}\n\n\\paragraph{$\\mathcal{L}_\\infty$-norm}\n\\begin{equation}\n\t||x||_\\infty\n\t=\n\t\\sup_{t \\geq 0} |x(t)|\n\\end{equation}\n\n\n%!TEX root = TTK4215-Summary.tex\n\\subsection{Models for dynamic systems}\n\n\\begin{equation}\n\t\\V{\\dot{x}}\n\t=\n\t\\M{A} \\V{x}\n\t+\n\t\\M{B} \\V{u}\n\\end{equation}\n\n\\begin{equation}\n\t\\V{y}\n\t=\n\t\\M{C}\\T \\V{x}\n\\end{equation}\n\n\\paragraph{Controllability}\n\\begin{equation}\n\t\\M{P}_c\n\t\\triangleq\n\t\\begin{bmatrix}\n\t\t\\M{B} \\\\ \\M{AB} \\\\ \\vdots \\\\ \\M{A}^{n-1}\\M{B}\n\t\\end{bmatrix}\n\\end{equation}\n\nIf $\\M{P}_c$ is nonsingular, the system is controllable, and can be transformed to the \\emph{controllability canonical form} by\n\\begin{equation}\n\t\\V{x}_c\n\t=\n\t\\M{P}_c^{-1} \\V{x}\n\\end{equation}\n\n\\paragraph{Properness}\nA transfer function $\\M{G}(s) = \\frac{\\M{N}(s)}{\\M{D}(s)}$ is\n\\begin{itemize}\n\t\\item \\emph{proper} if $\\deg(\\M{N}) \\leq \\deg(\\M{D})$,\n\t\\item \\emph{biproper} if $\\deg(\\M{N}) = \\deg(\\M{D})$,\n\t\\item \\emph{stricly proper} if $\\deg(\\M{N}) < \\deg(\\M{D})$.\n\\end{itemize}\n\n\\subsection{Transfer function properties}\nConsider the polynomial\n\\begin{equation}\n\tX(s) = \\alpha_n s^n + \\alpha_{n-1} s^{n-1} + \\cdots + \\alpha_0\n\\end{equation}\nand the transfer function\n\\begin{equation}\n\tG(s) = \\frac{Z(s)}{R(s)}\n\t.\n\\end{equation}\n\n\\paragraph{Monic:} $X(s)$ is \\emph{monic} iff $\\alpha_n = 1$.\n\n\\paragraph{Hurwitz:} $X(s)$ is \\emph{Hurwitz} if all roots of $X(s) = 0$ are in the left half plane.\n\n\\paragraph{Minimum phase:} A system defined by the t.f. $G(s)$ is \\emph{minimum phase} iff $Z(s)$ is Hurwitz.\n\n\\paragraph{Stability:} A system defined by the t.f. $G(s)$ is \\emph{stable} if $R(s)$ is Hurwitz.\n\n\\paragraph{Coprime:} Two polynomials are \\emph{coprime} if they have no common factors other than a constant.\n\n\\subsection{(Strictly) positive real transfer functions}\n\n\\subsection{Positive Real (PR)}\n\\paragraph{Definition 3.5.1}\nA rational function $G(s)$ of the complex variable $s=\\sigma + j\\omega$ is called PR if\n\\begin{itemize}\n\t\\item $G(s)$ is real for real $s$\n\t\\item $\\Re[G(s)] \\geq 0 \\quad \\forall \\quad \\sigma > 0$\n\\end{itemize}\n\n\\paragraph{Lemma 3.5.1}\nA rational proper transfer function $G(s)$ is PR iff\n\\begin{itemize}\n\t\\item $G(s)$ is real for real $s$\n\t\\item $G(s)$ is analytic in $\\Re[s] \\geq 0$, and the poles on the $j\\omega$-axis are simple and such that the associated residues are real and positive.\n\t\\item For all real value $\\omega$ for which $s = j \\omega$ is not a pole of $G(s)$, one has $\\Re[G(j\\omega)]$\n\\end{itemize}\n\n\\subsection{Strict Positive Real (SPR)}\n\\paragraph{Definition 3.5.2}\nAssume $G(s)$ is not identically zero for all $s$. Then $G(s)$ is SPR if $G(s-\\epsilon)$ is PR for some $\\epsilon > 0$.\n\n\\paragraph{Theorem 3.5.2}\n(Necessary and sufficient conditions.) Assume that a rational function $G(s)$ of the complex variable $s = \\sigma + j\\omega$ is real for real $s$ and is not identically zero for all $s$. Let $n^*$ be the relative degree of $G(s) = Z(s) / R(s)$ with $|n^*| \\leq 1$. Then, $G(s)$ is SPR iff\n\\begin{itemize}\n\t\\item $G(s)$ is analytic for $\\sigma \\geq 0$\n\t\\item $\\Re[G(j\\omega)] > 0 \\quad \\forall \\quad \\omega$\n\t\\item When $n^* = 1, \\quad \\lim_{|\\omega| \\to \\infty} \\omega \\Re[G(j\\omega)] > 0 $\n\t\\item When $n^* = -1,\\quad \\lim_{|\\omega| \\to \\infty} \\frac{G(j\\omega)}{j\\omega} >0 $\n\\end{itemize}\n\n\\paragraph{Corollary 3.5.1}\n\\begin{itemize}\n\t\\item $G(s)$ is PR/SPR iff $1/G(s)$ is PR/SPR\n\t\\item If $G(s)$ is SPR, then, $|n^*| \\leq 1$, and the zeros and poles of $G(s)$ lie in $\\Re[s]<0$.\n\t\\item When $n^* = 1, \\quad \\lim_{|\\omega| \\to \\infty} \\omega \\Re[G(j\\omega)] > 0 $\n\t\\item When $n^* = -1,\\quad \\lim_{|\\omega| \\to \\infty} \\frac{G(j\\omega)}{j\\omega} >0 $\n\\end{itemize}\n\n\\paragraph{KYP Lemma (3.5.2)}\nGiven a square matrix $A$ with eigenvalues $\\Re(\\lambda) \\leq 0$, a vector $B$ such that $(A,B)$ controllable, a vector $C$, and scalar $d \\geq 0$, then the t.f.\n\\begin{equation}\n\tG(s) = d + C\\T (s \\mathrm{I} - A)^{-1} B\n\\end{equation}\nis PR iff $\\exists$ a symmetric pos. def. matrix $P$ and a vector $q$ such that\n\\begin{gather}\n\tA\\T P + P A = -q q\\T \\\\\n\tP B - C = \\pm \\sqrt{2d} \\cdot q\n\t.\n\\end{gather}\n\n\\paragraph{LKY Lemma (3.5.3)}\nGiven a stable matrix $A$, a vector $B$ such that $(A,B)$ controllable, a vector $C$ and a scalar $d \\geq 0$, then the t.f.\n\\begin{equation}\n\tG(s) = d + C\\T (s \\mathrm{I} - A)^{-1} B\n\\end{equation}\nis SPR iff for any pos. def. matrix $L$, $\\exists$ a symmetric pos. def. matrix $P$, a scalar $\\nu > 0$ and a vector $q$ such that\n\\begin{gather}\n\tA\\T P + P A = -q q\\T - \\nu L \\\\\n\tP B - C = \\pm q \\sqrt{2d}\n\t.\n\\end{gather}\n\n\\paragraph{MKY Lemma (3.5.4)}\nGiven a stable matrix $A$, vectors $B,C$, and a scalar $d \\geq 0$, we have: If\n\\begin{equation}\n\tG(s) = d + C\\T (s \\mathrm{I} - A)^{-1} B\n\\end{equation}\nis SPR, then for any $L = L\\T > 0$, $\\exists$ a scalar $\\nu > 0$, a vector $q$ and a $P = P\\T > 0$ such that\n\\begin{gather}\n\tA\\T P + P A = -q q\\T - \\nu L \\\\\n\tP B - C = \\pm q \\sqrt{2d}\n\t.\n\\end{gather}", "meta": {"hexsha": "2b3aad6c5ef4594117b272382a398cf4e3e6e718", "size": 5158, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TTK4215 System identification and adaptive control/sec-preliminaries.tex", "max_stars_repo_name": "jakoblover/ntnu-course-summaries", "max_stars_repo_head_hexsha": "8ba859de2349b93c5079ca10a4cf2ec49c1f5dc0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-05-30T09:19:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-11T02:42:40.000Z", "max_issues_repo_path": "TTK4215 System identification and adaptive control/sec-preliminaries.tex", "max_issues_repo_name": "jakoblover/ntnu-course-summaries", "max_issues_repo_head_hexsha": "8ba859de2349b93c5079ca10a4cf2ec49c1f5dc0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TTK4215 System identification and adaptive control/sec-preliminaries.tex", "max_forks_repo_name": "jakoblover/ntnu-course-summaries", "max_forks_repo_head_hexsha": "8ba859de2349b93c5079ca10a4cf2ec49c1f5dc0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6455696203, "max_line_length": 288, "alphanum_fraction": 0.6297014347, "num_tokens": 2033, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850093037731, "lm_q2_score": 0.9005297847831081, "lm_q1q2_score": 0.8431525379239772}} {"text": "\\section{Norm and distance}\n\\subsection{Norm} \n\\textit{Euclidean norm} (or just norm) is\\\\\n$||x||= \\sqrt{x_1^2+x_2^2+...+x_n^2}= \\sqrt{x^Tx}$\\\\\n\\textbf{Properties}\\\\\n\\textbullet homogeneity: $||\\beta x|| = |\\beta ||x|||$\\\\\n\\textbullet triangle inequality: $||x + y|| \\leq ||x|| + ||y||$\\\\\n\\textbullet non negativity: $||x|| \\geq 0$\\\\\n\\textbullet definiteness: $||x|| = 0$ only if x = 0\\\\\n\\textit{positive definiteness} = non negativity + definiteness\\\\\n\\textbf{rms}(x) = $\\sqrt{\\frac{x_1^2+...+x_n^2}{n}} = \\frac{||x||}{\\sqrt{n}}$ \\\\\n\\textbullet \\textit{Norm of a sum}:\\\\ \n$\\Vert a + b \\Vert^2 = (x + y)^T(x + y) = \\Vert x \\Vert^2 + 2x^Ty + \\Vert b \\Vert^2$\\\\\n\\textbf{Norm of block vectors}\n$||(a,b,c)|| = \\sqrt{||a||^2 + ||b||^2 + ||c||^2} = ||(||a||, ||b||, ||c||)||$\\\\\n\\textbf{Chebyshev inequality}\nk of its entries satisfy $|x_i| \\geq a$, \\\\then $\\frac{k}{n} \\leq (\\frac{\\textbf{rms}(x)}{a})^2$\n\\subsection{Distance}\n$\\textbf{dist}(a,b) = ||a - b||$\\\\\n\\textit{Triangle Inequality}: $||a - c||^2 = ||(a - b) + (b - c)|| \\leq ||a-b|| + ||b-c||$\\\\\n$z_j$ is the nearest neighbor of x if $||x-z_j|| \\leq ||x-z_i||, i=1,..,m$\\\\\n\n\\subsection{Standard Deviation}\nde-meaned vector: $\\tilde{x} = x - \\textbf{avg}(x)\\textbf{1}$\\\\\nstandard deviation: \\\\\\textbf{std}(x) = \\textbf{rms}($\\tilde{x}$) = $\\frac{||x - (\\textbf{1}^Tx/n)\\textbf{1}||}{\\sqrt{n}}$\\\\\n${\\textbf{rms}(x)}^2 = {\\textbf{avg}(x)}^2 + {\\textbf{std}(x)}^2$\\\\\nBy Chebyshev inequality, $|x_i - \\textbf{avg}(x)| \\geq \\alpha \\textbf{std}(x)$ then $k/n \\leq (std(x)/a)^2$. (This inequality is only interesting for $a > std(x)$) \\\\\n\\textit{Cauchy–Schwarz inequality}: $|a^Tb| \\leq \\Vert a\\Vert \\Vert b \\Vert$\n\\subsection{Angle}\nangle between two nonzero vectors a, b defined as\\\\\n$\\angle(a,b) = arccos(\\frac{a^Tb}{\\Vert a \\Vert \\Vert b \\Vert})$\\\\\n$a^Tb = \\Vert a \\Vert \\Vert b \\Vert cos (\\angle(a,b))$\\\\\n\\textbf{Classification of angles}\\\\\n\n$\\theta = \\pi/2$: $a \\perp b$\\\\\n$\\theta = 0$: $a^Tb = \\Vert a \\Vert \\Vert b \\Vert$\\\\\n$\\theta = \\pi = 180^{\\circ}$ : $a^Tb = -\\Vert a \\Vert \\Vert b\\Vert$\\\\\n$\\theta \\leq \\pi/2 = 90^{\\circ} = a^Tb \\geq 0$\\\\\n$\\theta \\geq \\pi/2 = 90^{\\circ} = a^Tb \\leq 0$\\\\\n\\textbf{Correlation Coeficient ($\\rho$)}\n$\\rho = \\frac{\\tilde{a}^T\\tilde{b}}{\\Vert\\tilde{a}\\Vert\\Vert\\tilde{b}\\Vert}$\\\\\nWith $u = \\tilde{a}/\\textbf{std}(a)$ \\& $u = \\tilde{b}/\\textbf{std}(b)$, \\\\\n$\\rho = u^Tv/n$ where $\\Vert u \\Vert = \\Vert v \\Vert = n$\\\\\n\n$std(a+b) = \\\\\n\\sqrt{std(a)^2+ 2\\rho std(a)std(b) +std(b)^2}$\\\\\n\\textbf{Properties of standard deviation}\\\\\n\\textbullet $\\textbf{std}(x+a1) = \\textbf{std}(x)$\\\\\n\\textbullet $\\textbf{std}(ax) = |a| std(x)$\\\\\n\\textbf{Standardization}\n$z = \\frac{1}{\\textbf{std}(x)}(x - \\textbf{avg}(x)\\textbf{1})$\n\n\\subsection{Complexity}\n\\textbullet \\textit{norm}: 2n\\\\\n\\textbullet \\textit{\\textbf{rms}}: 2n\\\\\n\\textbullet \\textit{\\textbf{dist}(a,b)}: 3n\\\\\n\\textbullet \\textit{$\\angle(a,b)$}: 6n\\\\\n", "meta": {"hexsha": "7ed3a3b53092e43a5a5b522df93e7affc47f84e3", "size": 2882, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_stars_repo_name": "meanmachin3/COT5615", "max_stars_repo_head_hexsha": "fa14d5a297b10e79cdc69e9aee67f8a1744d9340", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2019-10-03T00:00:36.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-26T00:44:47.000Z", "max_issues_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_issues_repo_name": "meanmachin3/COT5615", "max_issues_repo_head_hexsha": "fa14d5a297b10e79cdc69e9aee67f8a1744d9340", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cheatsheet/inhalt/chapter3.tex", "max_forks_repo_name": "meanmachin3/COT5615", "max_forks_repo_head_hexsha": "fa14d5a297b10e79cdc69e9aee67f8a1744d9340", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2019-10-01T14:09:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-11T20:02:53.000Z", "avg_line_length": 49.6896551724, "max_line_length": 166, "alphanum_fraction": 0.5801526718, "num_tokens": 1242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.936285002192296, "lm_q2_score": 0.9005297861178929, "lm_q1q2_score": 0.8431525327696192}} {"text": "\\section{First and Second Derivative Tests}\r\n\\subsection{First Derivative Test}\r\nAs we saw in previous sections, we can use the first derivative to find critical values, which allow us to find extrema.\r\n\\begin{theorem}[First Derivative Test]\r\n\tLet $f(x)$ be a continuous function.\r\n\tAt a critical point $c$,\r\n\t\\begin{enumerate}\r\n\t\t\\item If $f^\\prime$ changes sign from positive to negative ($f^\\prime(x) > 0$ for $x < c$ and $f^\\prime(x) < 0$ for $x > c$), then $f$ has a local maximum at $c$.\r\n\t\t\\item If $f^\\prime$ changes sign from negative to positive ($f^\\prime(x) < 0$ for $x < c$ and $f^\\prime(x) > 0$ for $x > c$), then $f$ has a local minimum at $c$.\r\n\t\t\\item If $f^\\prime$ does not change sign at $c$, then $f$ does not have a local extrema at $c$.\r\n\t\t\\item At a left endpoint $a$, if ($f^\\prime < 0$ / $f^\\prime > 0$), then $f$ has a local (maximum / minimum) at $a$.\r\n\t\t\\item At a right endpoint $b$, if ($f^\\prime < 0$ / $f^\\prime > 0$), then $f$ has a local (minimum / maximum) at $b$.\r\n\t\\end{enumerate}\r\n\\end{theorem}\r\n\r\n\\begin{example}\r\n\tFind the local extrema of $f(x) = x^3 - 12x - 5$.\r\n\tIdentify any absolute extrema.\r\n\\end{example}\r\n\\begin{answer}\r\n\tTaking the derivative,\r\n\t\\begin{equation*}\r\n\t\tf^\\prime(x) = 3x^2 - 12 = 3(x+2)(x-2).\r\n\t\\end{equation*}\r\n\t\r\n\tSo, the critical values are $x=-2$ and $x=2$.\r\n\t$f^\\prime$ is negative between these values and positive outside of them, so $x=-2$ is a local maximum, while $x=2$ is a local minimum.\r\n\t\\begin{equation*}\r\n\t\tf(-2) = 11 \\text{ and } f(2) = -21.\r\n\t\\end{equation*}\r\n\t\r\n\tAs $x$ approaches $\\infty$ (the right endpoint), $f$ also approaches $\\infty$, so there is no absolute maximum.\r\n\tSimilarly, as $x$ approaches $-\\infty$ (the left endpoint), $f$ also approaches $-\\infty$, so there is no absolute minimum.\r\n\\end{answer}\r\n\r\n\\subsection{Second Derivative Test}\r\nThe second derivative tells us how the derivative is changing.\r\nWhether the derivative is increasing or decreasing describes the concavity.\r\n\\begin{definition}\r\n\tOn some open interval $I$, the graph of a twice differentiable function $f(x)$ is\r\n\t\\begin{enumerate}\r\n\t\t\\item Concave up if $f^{\\prime\\prime} > 0$ on $I$.\r\n\t\t\\item Concave down if $f^{\\prime\\prime} < 0$ on $I$.\r\n\t\\end{enumerate}\r\n\\end{definition}\r\n\r\n\r\nConcave up portions of a graph tend to look like valleys, while concave down portions tend to look like hills.\r\nUnlike the first derivative, we can tell if a function is increasing or decreasing using concavity.\r\nWe can however say if the function is increasing or decreasing more or less rapidly.\r\n\r\n\\begin{figure}[H]\r\n\t\\label{mvt}\r\n\t\\centering\r\n\t\\includegraphics[width = 0.5\\textwidth]{./applications_derivative/concavity.png}\r\n\t\\caption{\\hyperref{https://tutorial.math.lamar.edu/classes/calci/shapeofgraphptii.aspx}{}{}{Paul's Online Notes - The Shape of a Graph, Part II}}\r\n\\end{figure}\r\n\r\n\r\nThe points where a function changes concavity are called \"inflection points\".\r\nAt these points, the function is increasing or decreasing most rapidly, depending on the sign of the first derivative.\r\n\r\n\r\nRather than looking at the sign of $f^\\prime$ around critical values, we can look at the concavity at the critical point.\r\n\\begin{theorem}[Second Derivative Test]\r\n\tLet $c$ be a critical value of $f$.\r\n\t\\begin{enumerate}\r\n\t\t\\item If $f^{\\prime\\prime}(c) < 0$, then $c$ is a local maximum.\r\n\t\t\\item If $f^{\\prime\\prime}(c) > 0$, then $c$ is a local minimum.\r\n\t\t\\item If $f^{\\prime\\prime}(c) = 0$, then the test is inclusive.\r\n\t\\end{enumerate}\r\n\\end{theorem}\r\n\r\nIn other words, if we're at a critical point that's turning into a valley, then the critical point must be the top of a hill.\r\nIf we're at a critical point that's turning into a hill, then the critical point must be the bottom of a valley.\r\nThis test is particularly useful because you only need to know $f^{\\prime\\prime}$ at $c$ rather than an entire interval\\footnote{It also extends to higher dimensions much better than the first derivative test.}.\r\n\r\n\\begin{example}\r\n\tUse the second derivative test to find the local extreme values of $f(x) = x^3 - 12x - 5$.\r\n\\end{example}\r\n\\begin{answer}\r\n\tFinding critical values,\r\n\t\\begin{align*}\r\n\t\tf^\\prime(x) &= 3x^2 - 12 = 3(x+2)(x-2). \\\\\r\n\t\tf^\\prime(x) &= 0\\text{ at } x=-2, x=2.\r\n\t\\end{align*}\r\n\t\r\n\tTaking the second derivative,\r\n\t\\begin{equation*}\r\n\t\tf^{\\prime\\prime}(x) = 6x.\r\n\t\\end{equation*}\r\n\t\r\n\tEvaluating the second derivative at the critical values,\r\n\t\\begin{equation*}\r\n\t\tf^{\\prime\\prime}(-2) = -12 \\text{ and } f^{\\prime\\prime}(2) = 12.\r\n\t\\end{equation*}\r\n\t\r\n\tSo, $x=-2$ is a local maximum and $x=2$ is a local minimum.\r\n\\end{answer}", "meta": {"hexsha": "dc2353bed1a577099913477f9e11f8dc3765710e", "size": 4602, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/applications_derivative/first_second_derivative_test.tex", "max_stars_repo_name": "rawsh/Math-Summaries", "max_stars_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "calc/applications_derivative/first_second_derivative_test.tex", "max_issues_repo_name": "rawsh/Math-Summaries", "max_issues_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "calc/applications_derivative/first_second_derivative_test.tex", "max_forks_repo_name": "rawsh/Math-Summaries", "max_forks_repo_head_hexsha": "3ad58ef55c176f7ebaf145144e0a4eb720ebde86", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.4848484848, "max_line_length": 212, "alphanum_fraction": 0.6823120382, "num_tokens": 1412, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297781091839, "lm_q2_score": 0.936285003525698, "lm_q1q2_score": 0.8431525264719533}} {"text": "\\section*{Exercise 20.3-5}\n\\subsection*{Running times for the modified operations}\n\nThe recursive procedures that implement the vEB tree operations have running times characterized by the recurrence\n$$\nT(u) \\leq T(u^{1/k}) + T(u^{1-1/k}) + O(1),\n$$\nwhere the first part is due to the number of clusters, and the second part is due to the size of the clusters, which are enumerated.\n\\\\\nBy letting $m=\\lg u$, such that $u=2^m$, then\n$$\nT(2^m) \\leq T(2^{m/k}) + T(u^{m-m/k}) + O(1)\n$$\nWe then rename $S(m)=T(2^m)$, which results in\n$$\nS(m) \\leq S(m/k) + S(m-m/k) + O(1) = S(m/k) + S\\left(\\frac{m(k-1)}{k}\\right) + O(1)\n$$\nFor $k>2$, the second part will dominate, so in terms of running time, we can \"ignore\" the first term. In this case, case 2 of the master theorem applies, and $S(m)$ has the solution $S(m)=O(\\lg m)$.\nBy changing back, we can conclude, that\n$$\nT(u) = T(2^m) = S(m) = O(\\lg m) = O(\\lg\\lg u)\n$$", "meta": {"hexsha": "46b5b51739210df03f1eacb1f460ad9975ff2c25", "size": 910, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Uge3/Ex.20.3-5.tex", "max_stars_repo_name": "pdebesc/AADS", "max_stars_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Uge3/Ex.20.3-5.tex", "max_issues_repo_name": "pdebesc/AADS", "max_issues_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Uge3/Ex.20.3-5.tex", "max_forks_repo_name": "pdebesc/AADS", "max_forks_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.3636363636, "max_line_length": 199, "alphanum_fraction": 0.6428571429, "num_tokens": 324, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9724147209709196, "lm_q2_score": 0.8670357701094303, "lm_q1q2_score": 0.8431183464627682}} {"text": "\\chapter{Metric Definitions}\n\n\\section{Pixel Error}\nGiven two images, pixel error is defined as the mean of the absolute numerical distance between corresponding pixels in both images. Formally, we define:\n\n$$P(X, Y) = \\frac{\\sum_{\\bm{i} \\in S}{|X_{\\bm{i}} - Y_{\\bm{i}}|}}{|S|}$$\nfor tensors $X$ and $Y$ over all indexes $\\bm{i}$ in the index space $S$ for tensors $X$ and $Y$.\n\n\\section{Rand Score}\n\nThe version of the Rand Score used in this thesis is the Rand F Score. The Rand F Score essentially counts all the non-distinct pairs in an image that are correctly labeled as belonging to the same or different grouping with respect to a reference image. Formally, we define $S_1, S_2, ... S_n \\subseteq S$ to be the set of all groupings $S_i$ in an input volume (i.e. distinct labels in a segmentation)m and $T_1, T_2, ... T_n \\subseteq T$ to be the set of all groupings $T_i$ in a ground-truth volume. Let:\n\n$$ t_i = |T_i| $$\n$$ s_i = |S_i| $$\n$$ c_{i,j} = |S_i \\cap T_j| $$\n\nThen, the Rand F Score can be defined as:\n\n$$R_{\\mathsf{Full}}(S,T) = \\frac{\\sum_{i,j}{c_{i,j}}}{\\alpha \\sum_{i}{s_i^2} + (1 - \\alpha)\\sum_j{t_i^2}}$$ \n\n$$R_{\\mathsf{Merge}}(S,T) = \\frac{\\sum_{i,j}{c_{i,j}}}{\\sum_{i}{s_i^2}}$$ \n\n$$R_{\\mathsf{Split}}(S,T) = \\frac{\\sum_{i,j}{c_{i,j}}}{\\sum_{j}{t_j^2}}$$ \n\n\nwhere $N$ is the number of voxels in a volume. See \\url{https://github.com/seung-lab/segascorus/blob/master/segerror-manual.pdf} for more details of the Rand F Score.\n\n\\section{Cross Correlation}\n\nGiven two images, cross-correlation is defined as the mean of the prodiuct of corresponding pixels in both images. Formally, we define:\n\n$$C(X, Y) = \\frac{\\sum_{\\bm{i} \\in S}{|X_{\\bm{i}} \\times Y_{\\bm{i}}|}}{|S|}$$\nfor tensors $X$ and $Y$ over all indexes $\\bm{i}$ in the index space $S$ for tensors $X$ and $Y$.\n\n\\subsection{Smoothed Version}\n\nBecause standard Cross Correlation is not particularly continuous (i.e. two images will typically be highly correlated if they match exactly, and loosely correlated if they are translated or rotated), we define a somewhat more smoothed version that attempts to make the function more continuous. We define the function:\n\n$$C_s(X, Y) = \\frac{\\sum_{\\bm{i} \\in S}{|X_{\\bm{i}} \\times (G_{\\theta}(Y))_{\\bm{i}}|}}{|S|}$$\nfor tensors $X$ and $Y$ over all indexes $\\bm{i}$ in the index space $S$ for tensors $X$ and $Y$. The function $G_{\\theta}(\\cdot)$ is a smoothing function, which applies a Gaussian filter to its arguments based on parameters $\\theta$. The amount of smoothing that occurs determines how dontinuous the smoothed cross-correlation function is. Because the continuity of this function can be controlled, it makes for a more-useful loss function than standard Cross Correlation.", "meta": {"hexsha": "6786724bf84f5be1816a2f5cbc41d95f14ee5f3e", "size": 2717, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "tex/appendix.tex", "max_stars_repo_name": "beneisner/ugrad-thesis", "max_stars_repo_head_hexsha": "b6c819acca262e8578e638c43be8115447bdcdbf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tex/appendix.tex", "max_issues_repo_name": "beneisner/ugrad-thesis", "max_issues_repo_head_hexsha": "b6c819acca262e8578e638c43be8115447bdcdbf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tex/appendix.tex", "max_forks_repo_name": "beneisner/ugrad-thesis", "max_forks_repo_head_hexsha": "b6c819acca262e8578e638c43be8115447bdcdbf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 67.925, "max_line_length": 508, "alphanum_fraction": 0.7007729113, "num_tokens": 823, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9744347838494567, "lm_q2_score": 0.865224072151174, "lm_q1q2_score": 0.843104431727976}} {"text": "\\section{Theory}\n\\label{sec:theory}\n\n\\subsection{Gradient Descent}\nThe aim of Stochastic Gradient Descent is to minimize the neural network' cost function with respect to its weights.\nThe algorithm initializes the weights to random values.\nThen, it iteratively select some training example $\\nu$ from the training dataset $\\mathbb{D}_{train}$ and updates the weights by some fraction $\\eta$ (usually called learning rate) of the gradient $\\nabla_{w_j} e^\\nu$ of the cost function $e^\\nu$ with respect to the network's weights $w_j$:\n\\begin{equation}\n \\label{eq:weights-update}\n w_j \\leftarrow w_j - \\eta \\cdot \\nabla_{w_j} e^\\nu.\n\\end{equation}\n\nIn order to use this iterative procedure, we need to define a proper cost function for the regression problem.\nA common choice is to use the squared error for the current example $\\varepsilon^\\nu$:\n\\begin{equation}\n \\label{eq:cost}\n e^\\nu = \\frac{1}{2} (\\sigma(\\varepsilon^\\nu) - \\tau(\\varepsilon^\\nu))^2,\n\\end{equation}\nwhere $\\tau(\\varepsilon^\\nu))$ denotes the correct prediction for the current example.\n\nAnother possibility is to use all training examples (or a batch of them) to perform a single update, i.e. using the following cost function instead of $e$:\n\\begin{equation}\n \\label{eq:cost-total}\n E = \\frac{1}{2} \\frac{1}{M} \\sum_{\\mu = 1}^{M} (\\sigma(\\varepsilon^\\mu) - \\tau(\\varepsilon^\\mu))^2.\n\\end{equation}\nIn this case, we usually talk of Gradient Descent (or Batch Gradient Descent) instead of Stochastic Gradient Descent.\n\n\\subsection{Gradient Computation}\nThe hidden units in out network take as input the training examples $\\varepsilon$ and use the hyperbolic tangent as the activation function:\n\\begin{equation}\n g(\\varepsilon) = tanh(w \\cdot \\varepsilon)\n\\end{equation}\n\nSince we have only $2$ hidden units and the output unit simply computes the sum of the outputs of the hidden layer, the final predicted value is computed as:\n\\begin{equation}\n \\sigma (\\varepsilon) = tanh(w_1 \\cdot \\varepsilon) + tanh(w_2 \\cdot \\varepsilon),\n\\end{equation}\nwhere $w_1$ and $w_2$ are the weights' vectors.\n\nThe gradient of the cost function defined in \\cref{eq:cost} with respect to the weights $w_j$ for a single hidden unit $j$ can be computed as follows:\n\\begin{equation}\n \\label{eq:gradient-gen-weight}\n \\begin{split}\n \\nabla_{w_j} e^\\nu =\\; & (tanh(w_1 \\cdot \\varepsilon^\\nu) + tanh(w_2 \\cdot \\varepsilon^\\nu) - \\tau(\\varepsilon^\\nu)) \\; \\cdot \\\\\n & \\cdot (1 - tanh^2(w_j \\cdot \\varepsilon^\\nu)) \\cdot \\varepsilon^\\nu\n \\end{split}\n\\end{equation}\n", "meta": {"hexsha": "96de672bfcf6f28c09e07aa274c991404d413689", "size": 2551, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "assignment_3/report/02_theory.tex", "max_stars_repo_name": "davidepedranz/neural_networks_assignments", "max_stars_repo_head_hexsha": "262a2b33d5c3fe67bbeb20fa6ef1f4870bdfa9a0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assignment_3/report/02_theory.tex", "max_issues_repo_name": "davidepedranz/neural_networks_assignments", "max_issues_repo_head_hexsha": "262a2b33d5c3fe67bbeb20fa6ef1f4870bdfa9a0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assignment_3/report/02_theory.tex", "max_forks_repo_name": "davidepedranz/neural_networks_assignments", "max_forks_repo_head_hexsha": "262a2b33d5c3fe67bbeb20fa6ef1f4870bdfa9a0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.1458333333, "max_line_length": 292, "alphanum_fraction": 0.7240297922, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191259110588, "lm_q2_score": 0.8824278664544912, "lm_q1q2_score": 0.8430002180608651}} {"text": "\\chapter{The Dot Product}\n% Reference for diagrams:https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\nIf you have two vectors $u = [u_1, u_2, \\dots, w_n]$ and $v = [v_1, v_2,\\dots, v_n]$ , \nwe define the \\newterm{dot product} $u \\cdot v$ as \n\\begin{equation*}\n u \\cdot v = (u_1 \\times v_1) + (u_2 \\times v_2) + \\dots + (u_n \\times v_n)\n\\end{equation*} \n\nSo, for example, \n\\begin{equation*}\n [2,4, -3] \\cdot [5, -1, 1] = 2 \\times 5 + 4 \\times -1 + -3 \\times 1 = 3\n\\end{equation*}\\index{dot product}\n\nThis may not seem like a very powerful idea, but dot products are \\emph{incredibly} useful. \nThe enormous GPUs(Graphics Processing Unit) that let video games render scenes so quickly? \nThey are primarily function by computing huge numbers of dot products at mind-boggling speeds. \n\n\\begin{Exercise}[title={Basic dot products}, label=dot_products]\n Compute the dot product of each pair of vectors:\n \\begin{itemize}\n \\item $[1, 2, 3]$, $[4, 5, -6]$\n \\item $[\\pi, 2\\pi]$, $[2, -1]$\n \\item $[0,0,0,0]$, $[10,10,10,10]$\n \\end{itemize}\n\\end{Exercise}\n\\begin{Answer}[ref=dot_products]\n \\begin{itemize}\n \\item $[1, 2, 3] \\cdot [4, 5, -6] = 4 + 10 - 18 = -4$\n \\item $[\\pi, 2\\pi] \\cdot [2, -1] = 2\\pi - 2\\pi = 0$\n \\item $[0,0,0,0] \\cdot [10,10,10,10] = 0 + 0 + 0 + 0 = 0$ \n \\end{itemize}\n\\end{Answer}\n\n\\section{Properties of the dot product}\n\nSometimes we need an easy way to say ``The vector of appropriate length is filled with zeros.''\nWe use the notation $\\vec{0}$ to represent this. Then, for any vector $v$, this is true:\n\n$$v \\cdot \\vec{0} = 0$$\n\nThe dot product is commutative:\n\n$$v \\cdot u = u \\cdot v$$\n\nThe dot product of a vector with itself is its magnitude squared:\n\n$$ v \\cdot v = |v|^2 $$\n\nIf you have a scalar $a$ then:\n\n $$(v) \\cdot (a u) = a (v \\cdot u)$$\n\nSo, if $v$ and $w$ are vectors that go in the same direction,\n\n $$v \\cdot w = |v| |w|$$\n\nIf $v$ and $w$ are vectors that go in opposite directions,\n\n $$v \\cdot w = -|v| |w|$$\n\n\\section{Cosines and dot products}\n\nFurthermore, dot products' interaction with cosine makes them even more useful is what makes them so useful: \nIf you have two vectors $v$ and $u$,\n\n$$v \\cdot u = |v| |u| \\cos \\theta$$\n\nwhere $\\theta$ is the angle between them.\n\nSo, for example, if two vectors $v$ and $u$ are perpendicular, the angle between them is $\\pi/2$. \nThe cosine of $\\pi/2$ is 0: The dot product of any two perpendicular vectors is always 0. In fact, if \nthe dot product of two non-zero vectors is 0, the vectors \\textit{must be} perpendicular.\n% diagram needed \n\n\\begin{Exercise}[title={Using dot products}, label=cos_dot_products]\n What is the angle between these each pair of vectors:\n \\begin{itemize}\n \\item $[1, 0]$, $[0, 1]$\n \\item $[3,4]$, $[4,3]$\n \\end{itemize}\n\\end{Exercise}\n\\begin{Answer}[ref=cos_dot_products]\n \\begin{itemize}\n \\item $[1,0] \\cdot [0,1] = 0$. The angle must be $\\pi/2$.\n \\item $[3,4] \\cdot [4, 3] = 24$. $|[3,4]| |[4,3]| \\cos(\\theta) = 24$. \n $\\cos(\\theta) = \\frac{24}{(5)(5)}$. $\\theta = \\arccos(\\frac{24}{25}) \\approx 0.284 \\text{ radians}$.\n \\end{itemize}\n\\end{Answer}\n\nIf you have two non-zero vectors $v$ and $u$, you can always compute the angle between them:\\index{vectors!angle between}\n\n$$\\theta = \\arccos(\\frac{v \\cdot u}{|v| |u|})$$\n% Breif Description of arccos\n\\section{Dot products in Python}\n\nNumPy will let you do dot products using the the symbol @. Open \\filename{first\\_vectors.py} \nand add the following to the end of the script:\n\n\\begin{Verbatim}\n # Take the dot product\n d = v @ u\n print(\"v @ u =\", d)\n \n # Get the angle between the vectors\n a = np.arccos(d / (mv * mu))\n print(f\"The angle between u and v is {a * 180 / np.pi:.2f} degrees\") \n\\end{Verbatim}\n\nWhen you run it you should get:\n\\begin{Verbatim}\nv @ u = 4\nThe angle between u and v is 78.55 degrees\n\\end{Verbatim}\n\n\\section{Work and Power}\n%diagram here\nEarlier, we mentioned that mechanical work is the product of the \nforce you apply to something and the amount it moves. For example, if you \npush a train with a force of 10 newtons as it moves 5 meters, you have done 50 joules of work.\n\nWhat if you try to push the train sideways? That is, it moves down the track 5 meters, \nbut you push it as if you were trying to derail it -- perpendicular to its motion. \nYou have done no work because the train didn't move at all in the direction you were pushing.\n\nNow that you know about dot products: The work you do is the dot\nproduct of the force vector you apply and the displacement vector of the train. (The displacement\nvector is the vector that tells how the train moved while you pushed it.) \\index{work}\n\nSimilary, we mentioned that power is the product of the force you apply and the velocity of the\nmass you are applying it to. It is actually the dot product of the force vector and the velocity vector.\\index{power}\n\nFor example, if you are pushing sled with a force of 10 newtons and it is moving 2 meters per second, \nbut your push is 20 degrees off, you aren't transferring 20 watts of power to the sled. \nYou are transferring $10 \\times 2 \\times \\cos(20 \\text{ degrees}) \\approx 18.8$ watts of power.\n%add ramps and sin", "meta": {"hexsha": "b7f494fea7aa713b22168b4b1006ee9e01176382", "size": 5295, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Modules/TrianglesCircles/dot-en_US.tex", "max_stars_repo_name": "hillegass/sequence", "max_stars_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-06-13T17:19:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-05T00:43:44.000Z", "max_issues_repo_path": "Modules/TrianglesCircles/dot-en_US.tex", "max_issues_repo_name": "hillegass/sequence", "max_issues_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Modules/TrianglesCircles/dot-en_US.tex", "max_forks_repo_name": "hillegass/sequence", "max_forks_repo_head_hexsha": "b7b4896d804c49cbc93fe86a0d2fce531afbcc1f", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-05T00:43:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-05T00:43:58.000Z", "avg_line_length": 38.9338235294, "max_line_length": 121, "alphanum_fraction": 0.6602455146, "num_tokens": 1685, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582593509315, "lm_q2_score": 0.9059898165759306, "lm_q1q2_score": 0.8429857077209101}} {"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% CS624: Analysis of Algorithms\n% Copyright 2015 Pejman Ghorbanzade \n% Creative Commons Attribution-ShareAlike 4.0 International License\n% More info: https://github.com/ghorbanzade/beacon\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section*{Question 3}\n\nProve that if the subtree rooted at node $i$ has $n$ nodes, the subtree rooted at either of its children has size at most $2n/3$.\n\n\\subsection*{Solution}\n\nThe objective is to find an upper bound on the number nodes of a subtree based on number of nodes of a subtree rooted at its parent.\nWe define $H$ as the height of the latter subtree rooted at node $i$.\n\nTo find the upper bound, we try to place as many nodes as possible on a subtree $L$ rooted at a child of $i$ while trying to maintain as few nodes as possible on subtree $R$ at the other child of $i$.\nThis practice is however restricted by definition of the heap that requires all higher levels of the tree be completely filled.\nThus the difference would be on the lowest level where we are allowed to add nodes from the left.\n\nThe imbalance between subtrees $L$ and $R$ will be most significant where last row is half full, in which case subtree $L$ will have height $(H-1)$ while subtree $R$ will have height $(H-2)$, due to the fact that both are completely filled.\n\nIf number of nodes of left and right subtrees be defined as $n(L)$ and $n(R)$, respectively, the following would hold.\n\n\\begin{equation}\\label{eq31}\nn(L) = 2^{(H-1)+1}-1 = 2^H - 1\n\\end{equation}\n\n\\begin{equation}\\label{eq32}\nn(R) = 2^{(H-2)+1}-1 = 2^{H-1} - 1\n\\end{equation}\n\nsince roots of subtrees $L$ and $R$ are immediate children of node $i$ we will also have\n\n\\begin{equation}\\label{eq33}\nn = 1 + n(L) + n(R)\n\\end{equation}\n\nwhere $n$ is total number of nodes of a subtree with root at node $i$.\n\nSubstituting \\ref{eq31} and \\ref{eq32} into \\ref{eq33},\n\n\\begin{equation}\\label{eq34}\n\\begin{aligned}\nn &= 2^H + 2^{H-1} - 1\\\\\n&= 2^{H} (1 + \\frac{1}{2}) - 1\\\\\n&= \\frac{3}{2} n(L) + \\frac{1}{2}\n\\end{aligned}\n\\end{equation}\n\nwhich proves that $n(L) < \\frac{2}{3}n$.\n", "meta": {"hexsha": "3eca0f314cfb649b3bf0739c48f1dd27f7afef0e", "size": 2175, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "umb-cs624-2015s/src/tex/hw02/hw02q03.tex", "max_stars_repo_name": "ghorbanzade/beacon", "max_stars_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-13T20:00:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-01T11:16:51.000Z", "max_issues_repo_path": "umb-cs624-2015s/src/tex/hw02/hw02q03.tex", "max_issues_repo_name": "ghorbanzade/beacon", "max_issues_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "umb-cs624-2015s/src/tex/hw02/hw02q03.tex", "max_forks_repo_name": "ghorbanzade/beacon", "max_forks_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-20T05:58:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-06T17:18:05.000Z", "avg_line_length": 41.8269230769, "max_line_length": 240, "alphanum_fraction": 0.6666666667, "num_tokens": 644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475683211324, "lm_q2_score": 0.8933094088947399, "lm_q1q2_score": 0.8427012586392411}} {"text": "\\input{6DL/BarronSpace}\n\\subsection{Cosine function as activation function}\n\tConsider the Fourier transform:\n\t\\begin{equation}\n\t \\label{Fourier}\n\t \\hat f(\\omega)=\\frac{1}{(2\\pi)^d}\\int_{\\mathbb{R}^d}e^{-i\\omega\\cdot x}f(x)dx\n\t \\quad \\forall \\omega \\in \\mathbb R^d.\n\t\\end{equation}\n\tWe write \n\t$\\hat{f}(\\omega)=e^{i\\beta(\\omega)}|\\hat{f}(\\omega)|$. By Fourier inversion formula,\n\t\\begin{equation}\n\t\t\\label{eqn1}\n\t\tf(x)=\\int_{\\mathbb{R}^d}e^{i\\omega\\cdot x}\\hat{f}(\\omega)d\\omega\n\t\t=\\int_{\\mathbb{R}^d}e^{i(\\omega\\cdot x+\\beta(\\omega))}|\\hat{f}(\\omega)|d\\omega.\n\t\\end{equation}\nSince $f(x)$ is real-valued, it implies that, for $x$\n\t \\begin{equation}\n\t\t\\label{key}\n\t\t\\begin{aligned}\n\t\t\tf(x)\n\t\t\t&={\\rm Re}\\int_{\\mathbb{R}^d}\n\t\t\te^{i\\omega\\cdot x} \n\t\t\t\\hat{f}(\\omega)d\\omega \\\\\n\t\t\t&={\\rm Re}\\int_{\\mathbb{R}^d}\n\t\t\te^{i\\omega\\cdot x}\n\t\t\te^{i\\beta\n\t\t\t\t(\\omega)}|\\hat{f}(\\omega)|d\\omega \\\\\n\t\t\t&=\\int_{\\mathbb{R}^d}\\cos(\\omega\\cdot\n\t\t\tx+\\beta(\\omega))|\\hat{f}(\\omega)|d\\omega.\n\t\t\\end{aligned}\n\t\\end{equation}\n\tThen we have \n\t\\begin{equation}\\label{key}\n\tf(x) =\\int_{\\mathbb{R}^d}k(x,\\omega)d\\omega,\n\t\\end{equation}\n\twith\n\t\\begin{equation}\\label{key}\n\tk(x,\\omega) = \\cos(\\omega\\cdot\n\tx+\\beta(\\omega))|\\hat{f}(\\omega)|.\n\t\\end{equation}\n\tLet \n\t$$\n\t\\rho(\\omega) = |\\hat f(\\omega)|,\\qquad \\lambda(\\omega)={\\rho(\\omega)\\over \\|\\rho(\\omega)\\|_{L^1}}={\\rho(\\omega)\\over \\|\\hat f\\|_{L^1}}.\n\t$$ \n\t\n\\begin{theorem}\nThere exist $\\omega_i \\in \\mathbb{R}^d$, s.t., $G = \\mathbb{R}$ and \n\\begin{equation}\\label{key}\n\\| f(x) - f_n(x)\\|_{L^2} \\le \\frac{1}{\\sqrt{n}} \\int_{\\mathbb{R}^d} |\\hat f(\\omega)| d \\omega,\n\\end{equation}\nwhere\n\\begin{equation}\\label{key}\nf_n(x) = \\frac{\\|\\hat f\\|_{L^1}}{n} \\sum_{i=1}^n \\frac{ cos(\\omega^*_i \\cdot x + \\beta^*_i)}{\\rho(\\omega_i^*)}.\n\\end{equation}\n\\end{theorem}\nNote that \n\\begin{equation}\\label{key}\nf_n = \\frac{\\|\\hat f\\|_{L^1}}{n}\\sum_{i=1}^n \\frac{ cos(\\omega^*_i \\cdot x + \\beta^*_i)}{\\rho(\\omega_i^*)} \\in \\dnn(\\cos, n).\n\\end{equation} \n", "meta": {"hexsha": "9d0ef02799e11b8c454df4625b007532ecf63866", "size": 1965, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "6DL/FourierRepresentation.tex", "max_stars_repo_name": "liuzhengqi1996/math452", "max_stars_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "6DL/FourierRepresentation.tex", "max_issues_repo_name": "liuzhengqi1996/math452", "max_issues_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6DL/FourierRepresentation.tex", "max_forks_repo_name": "liuzhengqi1996/math452", "max_forks_repo_head_hexsha": "635b6ce53cb792e316abf4f47396f2e4f0686815", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.75, "max_line_length": 136, "alphanum_fraction": 0.6015267176, "num_tokens": 861, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.960361162033533, "lm_q2_score": 0.877476800298183, "lm_q1q2_score": 0.8426946395918293}} {"text": "\n\\subsection{Definition}\nLet’s add another function: addition. Defined by:\n\n\\(\\forall a \\in \\mathbb{N} (a+0=a)\\)\n\n\\(\\forall a b \\in \\mathbb{N} (a+s(b)=s(a+b))\\)\n\nThat is, adding zero to a number doesn’t change it, and \\((a+b)+1=a+(b+1)\\).\n\n\\subsection{Example}\n\nLet’s use this to solve \\(1+2\\):\n\n\\(1+2=1+s(1)\\)\n\n\\(1+s(1)=s(1+1)\\)\n\n\\(s(1+1)=s(1+s(0))\\)\n\n\\(s(1+s(0))=s(s(1+0))\\)\n\n\\(s(s(1+0))=s(s(1))\\)\n\n\\(s(s(1))=s(2)\\)\n\n\\(s(2)=3\\)\n\n\\(1+2=3\\)\n\nAll addition can be done iteratively like this.\n\n\\subsection{Commutative property of addition}\n\nAddition is commutative:\n\n\\(x+y=y+x\\)\n\n\\subsection{Associative property of addition}\n\nAddition is associative:\n\n\\(x+(y+z)=(x+y)+z\\)\n\n", "meta": {"hexsha": "63753b3a7d373809279b970dd782c8e8da96b218", "size": 671, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/logic/peano/01-01-addition.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/logic/peano/01-01-addition.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/logic/peano/01-01-addition.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.9111111111, "max_line_length": 76, "alphanum_fraction": 0.5946348733, "num_tokens": 266, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9697854103128328, "lm_q2_score": 0.8688267643505193, "lm_q1q2_score": 0.8425755201564393}} {"text": "\\documentclass[11pt]{amsart}\n\\usepackage{amsmath,amsfonts,amsthm,amssymb, amsaddr}\n\n\n\\title{Vector Calculus: Grad, Div, and Curl}\n\n\\author{Joe Bentley}\n\n\\date{\\today}\n\n\\begin{document}\n\n\\maketitle\n\n\\newpage\n\n\\section{Directional Derivative and Gradient}\n\nConsider a scalar field in three dimensions, given by $f(x, y, z)$. The partial derivatives $\\frac{\\partial f}{\\partial x}$, $\\frac{\\partial f}{\\partial y}$, and $\\frac{\\partial f}{\\partial z}$, are taking the derivatives along the $x$, $y$, and $z$ directions respectively. In other words, they are just like normal derivatives of a curve along a direction; they give the rate of change of $f$ along the given direction. What if we want the derivative in a direction other than $x$, $y$, and $z$? We can define the derivative in an arbitrary direction given by $\\hat{n}$ as,\n\n\\begin{align*}\n \\frac{\\partial f}{\\partial \\hat{n}} = \\lim_{\\epsilon \\to 0} \\frac{f(\\mathbf{r} + \\epsilon \\hat{n}) - f(\\mathbf{r})}{\\epsilon}\n\\end{align*}\n\nBy applying the chain rule to this, it follows,\n\n\\begin{align*}\n \\frac{\\partial f}{\\partial \\hat{n}} &= \\frac{d}{d\\epsilon} f(x + \\epsilon n_x, y + \\epsilon n_y, z + \\epsilon n_z) \\\\\n &= \\frac{\\partial f}{\\partial x} \\frac{d}{d\\epsilon} (x + \\epsilon n_x)\n + \\frac{\\partial f}{\\partial y} \\frac{d}{d\\epsilon} (y + \\epsilon n_y)\n + \\frac{\\partial f}{\\partial z} \\frac{d}{d\\epsilon} (z + \\epsilon n_z) \\\\\n &= n_x \\frac{\\partial f}{\\partial x} + n_y \\frac{\\partial f}{\\partial y} + n_z \\frac{\\partial f}{\\partial z}\n\\end{align*}\n\nTherefore, the directional derivative in a given direction $\\hat{n}$ is given by,\n\n\\begin{align*}\n \\frac{\\partial f}{\\partial \\hat{n}} = \\hat{n} \\cdot \\nabla f\n\\end{align*}\n\nWhere we define the gradient, $\\nabla f$ as,\n\n\\begin{align*}\n \\nabla f = \\frac{\\partial f}{\\partial x} \\hat{\\imath} + \\frac{\\partial f}{\\partial y} \\hat{\\jmath} + \\frac{\\partial f}{\\partial z} \\hat{k}\n\\end{align*}\n\nNote that $\\frac{\\partial f}{\\partial \\hat{n}} = \\hat{n} \\cdot \\nabla f$ has its maximum value $|\\nabla f|$ when $\\hat{n}$ is parallel to $\\nabla f$. The maximum value is $|\\nabla f|$ as $|\\hat{n}| = 1$. Hence $\\hat{n} = \\nabla f / |\\nabla f|$ is the direction in which $f$ is increasing most rapidly.\n\n\\section{Physical Interpretation of $\\nabla \\cdot \\mathbf{A}$}\n\nConsider an infinitesimal cuboid situated at the position $(x, y, z)$ with sides of length $dx$, $dy$, $dz$. We denote the surface integral as,\n\n\\begin{align*}\n \\oint_S \\mathbf{A} \\cdot d\\mathbf{S}\n\\end{align*}\n\nThe vector $\\mathbf{A} = A_x \\hat{\\imath} + A_y \\hat{\\jmath} + A_z \\hat{k}$. First we will consider two opposing faces of the cuboid both in the $\\hat{\\imath}$, denoted by the surfaces $S_1$ at $(x + dx, y, z)$ and $S_2$ at $(x, y, z)$. For the surface $S_1$, $d\\mathbf{S_1}$ is given by $d\\mathbf{S_1} = dy dz \\hat{\\imath}$. The vector $\\hat{\\imath}$ is the unit normal to the surface $S_1$. The surface integral is then given by,\n\n\\begin{align*}\n \\oint_{S_1} \\mathbf{A} \\cdot d\\mathbf{S} = A_x(x + dx, y, z) dy dz\n\\end{align*}\n\nFor the surface $S_2$, the surface element $d_\\mathbf{S_2}$ is given by $d_\\mathbf{S_2} = -dy dz \\hat{\\imath}$. Note that this time the unit normal is in the opposite direction to the unit normal in $d_\\mathbf{S_1}$. The surface integral this time is,\n\n\\begin{align*}\n \\oint_{S_2} \\mathbf{A} \\cdot d\\mathbf{S} = A_x(x, y, z) dy dz\n\\end{align*}\n\nBy adding together the two surface integrals,\n\n\\begin{align*}\n \\int_{S_1 + S_2} \\mathbf{A} \\cdot d\\mathbf{S} &= \\left[A_x(x + dx, y, z) - A_x(x, y, z)\\right] dy dz \\\\\n &= \\left[\\frac{\\partial A_x}{\\partial x} dx\\right] dy dz \\\\\n &= \\frac{\\partial A_x}{\\partial x} dx dy dz = \\frac{\\partial A_x}{\\partial x} dV\n\\end{align*}\n\nIn ths second line we recognised that it is the definition of the derivative multiplied by $dx$, so we can rewrite it as we have done the line after.\n\nWe get similar contributions for each of the other pairs of surfaces which we consider to find the final complete result,\n\n\\begin{align*}\n \\oint_S \\mathbf{A} \\cdot d\\mathbf{S} &= \\left[\\frac{\\partial A_x}{\\partial x} + \\frac{\\partial A_y}{\\partial y} + \\frac{\\partial A_z}{\\partial z}\\right] dx dy dz \\\\\n &= \\nabla \\cdot \\mathbf{A} dV\n\\end{align*}\n\nThe divergence of $\\mathbf{A}$ is therefore just the flux per unit volume of $\\mathbf{A}$.\n\nWe can construct a finite volume $V$ from infinitesimal cuboids. The surface integral can then be calculated by adding up the formulae for each cuboid and noting that the integrals over the internal surfaces cancel each other out. We are left with only the outside surface. From this we get the divergence theorem, also known as Gauss' theorem,\n\n\\begin{align*}\n \\oint_S \\mathbf{A} \\cdot d\\mathbf{S} = \\int_V (\\nabla \\cdot \\mathbf{A}) dV\n\\end{align*}\n\nwhere $S$ is the boundary of $V$. ($S = \\partial V$)\n\n\\section{The Continuity Equation}\n\nConsider a volume $V$ bounded by a surface $S = \\partial V$. The only way a conserved charge can change within the volume $V$ is if there is a current flow (flow of charge) across $S$. We can see that the rate of decrease of charge within $V$ is equal to the current flow across $S$,\n\n\\begin{align*}\n \\frac{\\partial}{\\partial t} \\int_V \\rho dV = - \\oint_S \\mathbf{j} \\cdot d \\mathbf{S}\n\\end{align*}\n\nwhere $\\rho$ is the charge density and $\\mathbf{j}$ is the current density (per unit area). Using the divergence theorem gives that the right hand side can be written such that,\n\n\\begin{align*}\n \\int_V \\frac{\\partial \\rho}{\\partial t} dV = - \\int_V \\nabla \\cdot \\mathbf{j} dV\n\\end{align*}\n\nWe have also taken the $\\partial/\\partial t$ into the integral. For this to be true for all volumes $V$, it is required that,\n\n\\begin{align*}\n \\frac{\\partial \\rho}{\\partial t} + \\nabla \\cdot \\mathbf{j} = 0\n\\end{align*}\n\nA familiar case is electric charge, where the density $\\rho(\\mathbf{r}, t)$ is the charge density, and $\\mathbf{j}(\\mathbf{r}, t)$ is the current density. Another example would be fluid flow, where the density $\\rho(\\mathbf{r}, t)$ is just the mass density, and for a velocity field $\\mathbf{v}(\\mathbf{r}, t)$, the mass current is given by $\\mathbf{j}(\\mathbf{r}, t) = \\rho(\\mathbf{r}, t)\\mathbf{v}(\\mathbf{r}, t)$. Thus in this case, due to mass conservation,\n\n\\begin{align*}\n \\frac{\\partial \\rho}{\\partial t} + \\nabla \\cdot (\\rho \\mathbf{V}) = 0\n\\end{align*}\n\nIn the case of an incompressible fluid flow, the density $\\rho$ is constant, and thus\n\n\\begin{align*}\n \\nabla \\cdot \\mathbf{v} = 0\n\\end{align*}\n\n\\section{Physical Interpretation of $\\nabla \\times \\mathbf{A}$}\n\nConsider an infinitesimal rectangle in the $xy$-plane situation at $(x, y)$ with sides of length $dx$ and $dy$. In this case we can write the circulation (the closed line integral) around the infinitesimal loop as,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = \\int_{C_1 + C_2 + C_3 + C_4} \\mathbf{A} \\cdot d\\mathbf{r}\n\\end{align*}\n\nWhere each $C_n$ is each side of the infinitesimal rectangle. For the first side $C_1$ we can write an infinitesimal element $d\\mathbf{r_1}$ as $d\\mathbf{r_1} = dx \\hat{\\imath}$. The unit vector $\\hat{\\imath}$ is the unit normal to the line. We can then write the surface integral as,\n\n\\begin{align*}\n \\int_{C_1} \\mathbf{A} \\cdot d\\mathbf{r_1} = A_x(x, y, z) dx\n\\end{align*}\n\nHere we have taken the dot product of $\\mathbf{A}$ and $d\\mathbf{r_1}$, and since this is only for $A_x$, there is no $\\hat{\\jmath}$ or $\\hat{k}$ component. For the side $C_3$ opposite the side $C_1$ we see that $d\\mathbf{r_3} = -dx \\hat{\\imath}$ as it is in the opposite direction to the unit normal of $C_1$. We can thus write the surface integral,\n\n\\begin{align*}\n \\int_{C_3} \\mathbf{A} \\cdot d\\mathbf{r_3} = -A_x(x, y + dy, z) dx\n\\end{align*}\n\nBy adding together these two line integrals we then see that,\n\n\\begin{align*}\n \\int_{C_1 + C_3} &= \\left[A_x(x, y, z) - A_x(x, y + dy, z)\\right] dx \\\\\n &= \\left[-\\frac{\\partial A_x}{\\partial y} dy\\right] dx = -\\frac{\\partial A_x}{\\partial y} dx dy\n\\end{align*}\n\nHere we have again noted that the $A_x$ terms are just the derivative of $A_x$ with respect to $y$, multiplied by $dy$.\n\nSimilarly we find that the other two sides $C_2$ and $C_4$ give,\n\n\\begin{align*}\n \\int_{C_2 + C_4} \\mathbf{A} \\cdot d\\mathbf{r} &= \\left[A_y(x + dx, y, z) - A_y(x, y, z)\\right] dy \\\\\n &= \\left[\\frac{\\partial A_y}{\\partial x} dx\\right] dy = \\frac{\\partial A_y}{\\partial x} dx dy\n\\end{align*}\n\nTherefore we can now calculate the integral over the entire rectangle,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = \\left[\\frac{\\partial A_y}{\\partial x} - \\frac{\\partial A_x}{\\partial y}\\right] dx dy\n\\end{align*}\n\nBy noting that in the square brackets is the cross product, we can also write it as the $z$ component of the cross product,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = {(\\nabla \\times \\mathbf{A})}_z dx dy\n\\end{align*}\n\nWe can also write the rectangle as a surface element $d\\mathbf{S}$ with a width $dx$ and height $dy$. We define the normal to this surface as being in the $\\hat{k}$ direction (this is where the cross product comes from) allowing to write the integral as,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = (\\nabla \\times \\mathbf{A}) \\cdot d\\mathbf{S}\n\\end{align*}\n\nNote that we no longer need just the $z$-component of the cross product as the dot product filters out just the component in the $\\hat{k}$ direction for us. From this result we can see that the $z$-component of the curl of $\\mathbf{A}$ is the circulation per unit area of $A$ in the $xy$-plane.\n\nGenerally, for an infinitesimal surface area $d\\mathbf{S} = \\hat{n} dS$ where $\\hat{n}$ is the unit normal, the circulation over the loop $C = \\partial S$ is given by,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = \\left(\\nabla \\times \\mathbf{A}\\right) \\cdot d\\mathbf{S}\n\\end{align*}\n\nWe can construct a finite surface $S$ from infinitestimal surface elements. We can do this by summing the above equation for each element and noting that the integrals over the internal loops cancel each other out. From this we get Stokes theorem,\n\n\\begin{align*}\n \\oint_C \\mathbf{A} \\cdot d\\mathbf{r} = \\int_S \\left(\\nabla \\times \\mathbf{A}\\right) \\cdot d\\mathbf{S}\n\\end{align*}\n\n\\section{Using Divergence and Curl with Maxwell's Equations}\n\nWe can use the divergence theorem and Stokes theorem to find the integral versions of Maxwell's equations.\n\nThis example shows finding the integral version of Gauss' law. The electric field lines diverge from electric charges such that,\n\n\\begin{align*}\n \\nabla \\cdot \\mathbf{E} = \\frac{\\rho(r)}{\\epsilon_0}\n\\end{align*}\n\nBy integrating both sides,\n\n\\begin{align*}\n \\int_V \\nabla \\cdot \\mathbf{E} dV &= \\int_V \\frac{\\rho(r)}{\\epsilon_0} dV \\\\\n \\oint_S \\mathbf{E} \\cdot d\\mathbf{S} &= \\frac{Q}{\\epsilon_0}\n\\end{align*}\n\nThis is the integral form of Gauss law.\n\nThis example shows finding the integral version of Amperes Law. The magnetic field lines curl around the electric currents,\n\n\\begin{align*}\n \\nabla \\times \\mathbf{B} &= \\mu_0 \\mathbf{j}(\\mathbf{r}) \\\\\n \\int_S \\left(\\nabla \\times \\mathbf{B}\\right) \\cdot d\\mathbf{S} &= \\int_S \\mu_0 \\mathbf{j}(\\mathbf{r}) d\\mathbf{S} \\\\\n \\oint_C \\mathbf{B} \\cdot d\\mathbf{r} &= \\mu_0 I\n\\end{align*}\n\n\\section{Vector Calculus Identities}\n\nIn this section we will prove many of the identities that we might need to know in vector calculus. These include vector calculus of sums, products, and multiple derivatives. First we will list which identities we need, and then we will go through and prove them all. In the following text, $v$ will mean vector, and $s$ will mean scalar.\n\nFirst we will consider the sums. There are two types of summations possible for scalar and vector fields,\n\n\\begin{align*}\n \\phi + \\psi \\qquad &\\text{(s + s = s)} \\\\\n \\mathbf{A} + \\mathbf{B} \\qquad &\\text{(v + v = v)}\n\\end{align*}\n\nSo we will need the formula for,\n\n\\begin{align*}\n &\\nabla(\\phi + \\psi) \\\\\n &\\nabla \\cdot (\\mathbf{A} + \\mathbf{B}) \\\\\n &\\nabla \\times (\\mathbf{A} + \\mathbf{B})\n\\end{align*}\n\nIn fact, we can consider general linear combinations of the scalar and vectors fields,\n\n\\begin{align}\n \\label{eq:1}\n &\\nabla(\\lambda \\phi + \\mu \\psi) \\\\\n \\label{eq:2}\n &\\nabla \\cdot (\\lambda \\mathbf{A} + \\mu \\mathbf{B}) \\\\\n \\label{eq:3}\n &\\nabla \\times (\\lambda \\mathbf{A} + \\mu \\mathbf{B})\n\\end{align}\n\nwhere $\\lambda$ and $\\mu$ are constants.\n\nNext we need the identities for products. There are four possible types of products,\n\n\\begin{align*}\n \\phi\\psi \\qquad &\\text{s $\\times$ s = s} \\\\\n \\phi\\mathbf{A} \\qquad &\\text{s $\\times$ v = v} \\\\\n \\mathbf{A} \\cdot \\mathbf{B} \\qquad &\\text{v $\\times$ v = s} \\\\\n \\mathbf{A} \\times \\mathbf{B} \\qquad &\\text{v $\\times$ v = v}\n\\end{align*}\n\nSo we will need the formula for,\n\n\\begin{align}\n \\label{eq:4}\n &\\nabla(\\phi\\psi) \\\\\n \\label{eq:5}\n &\\nabla\\cdot(\\phi\\mathbf{A}) \\\\\n \\label{eq:6}\n &\\nabla\\times(\\phi\\mathbf{A}) \\\\\n \\label{eq:7}\n &\\nabla(\\mathbf{A}\\cdot\\mathbf{B}) \\\\\n \\label{eq:8}\n &\\nabla\\cdot(\\mathbf{A}\\times\\mathbf{B}) \\\\\n \\label{eq:9}\n &\\nabla\\times(\\mathbf{A}\\times\\mathbf{B})\n\\end{align}\n\nAnd finally we need the multiple derivatives,\n\n\\begin{align}\n \\label{eq:10}\n &\\nabla\\cdot(\\nabla\\phi) \\\\\n \\label{eq:11}\n &\\nabla\\times(\\nabla\\phi) \\\\\n &\\nabla(\\nabla\\cdot\\mathbf{A}) \\notag\\\\\n \\label{eq:12}\n &\\nabla\\cdot(\\nabla\\times\\mathbf{A}) \\\\\n \\label{eq:13}\n &\\nabla\\times(\\nabla\\times\\mathbf{A})\n\\end{align}\n\nSo now we will start and find the identity for expression.~\\ref{eq:1}. Since this is vector, we only need to prove this for one component,\n\n\\begin{align*}\n &{\\left[\\nabla(\\lambda \\phi + \\mu \\psi)\\right]}_x = \\frac{\\partial}{\\partial x}\\left(\\lambda\\phi + \\mu\\psi\\right) \\\\\n =& \\lambda \\frac{\\partial \\phi}{\\partial x} + \\mu \\frac{\\partial \\psi}{\\partial x} = \\lambda{[\\nabla\\phi]}_x + \\mu{[\\nabla \\psi]}_x \\\\\n =& {\\left[\\lambda \\nabla \\phi + \\mu \\nabla \\psi\\right]}_x \\\\\n \\implies& \\nabla[\\lambda \\phi + \\mu \\psi] = \\lambda\\nabla\\phi + \\mu\\nabla\\psi\n\\end{align*}\n\nFor the second identity, we have to prove for each component as this isn't a vector as it is the scalar product,\n\n\\begin{align*}\n \\nabla\\cdot[\\lambda\\mathbf{A} + \\mu\\mathbf{B}] &= \\frac{\\partial}{\\partial x} {\\left[\\lambda \\mathbf{A} + \\mu \\mathbf{B}\\right]}_x + \\frac{\\partial}{\\partial y} {\\left[\\lambda \\mathbf{A} + \\mu \\mathbf{B}\\right]}_y + \\frac{\\partial}{\\partial z} {\\left[\\lambda \\mathbf{A} + \\mu \\mathbf{B}\\right]}_z \\\\\n &= \\frac{\\partial}{\\partial x} \\left[\\lambda A_x + \\mu B_x \\right] +\\frac{\\partial}{\\partial y} \\left[\\lambda A_y + \\mu B_y \\right] +\\frac{\\partial}{\\partial z} \\left[\\lambda A_z + \\mu B_z \\right] \\\\\n &= \\lambda \\frac{\\partial A_x}{\\partial x} + \\mu \\frac{\\partial B_x}{\\partial x} + \\lambda \\frac{\\partial A_y}{\\partial y} + \\mu \\frac{\\partial B_y}{\\partial y} + \\lambda \\frac{\\partial A_z}{\\partial z} + \\mu \\frac{\\partial B_z}{\\partial z} \\\\\n &= \\lambda \\left(\\frac{\\partial A_x}{\\partial x} + \\frac{\\partial A_y}{\\partial y} + \\frac{\\partial A_z}{\\partial z}\\right) + \\mu \\left(\\frac{\\partial B_x}{\\partial x} + \\frac{\\partial B_y}{\\partial y} + \\frac{\\partial B_z}{\\partial z}\\right) \\\\\n &= \\lambda \\nabla \\cdot \\mathbf{A} + \\mu \\nabla \\cdot \\mathbf{B}\n\\end{align*}\n\nTherefore we have for expression.~\\ref{eq:2},\n\n\\begin{align*}\n \\nabla\\cdot[\\lambda\\mathbf{A} + \\mu\\mathbf{B}] = \\lambda \\nabla \\cdot \\mathbf{A} + \\mu \\nabla \\cdot \\mathbf{B}\n\\end{align*}\n\nFor the third identity, we again have another vector as we are taking the cross product, so we only need to prove it for one component,\n\n\\begin{align*}\n {\\left[\\nabla\\times(\\lambda\\mathbf{A}+\\mu\\mathbf{B})\\right]}_x &= \\frac{\\partial}{\\partial y}{[\\lambda\\mathbf{A}+\\mu\\mathbf{B}]}_z - \\frac{\\partial}{\\partial z}{[\\lambda\\mathbf{A}+\\mu\\mathbf{B}]}_y \\\\\n &= \\frac{\\partial}{\\partial y}[\\lambda A_z+\\mu B_z] - \\frac{\\partial}{\\partial z}[\\lambda A_y+\\mu B_y] \\\\\n &= \\lambda\\left(\\frac{\\partial A_z}{\\partial y} - \\frac{\\partial A_y}{\\partial z}\\right) + \\mu\\left(\\frac{\\partial B_z}{\\partial y} - \\frac{\\partial B_y}{\\partial z}\\right) \\\\\n &= \\lambda{(\\nabla\\times\\mathbf{A})}_x + \\mu{(\\nabla\\times\\mathbf{A})}_x \\\\\n &= {[\\lambda(\\nabla\\times\\mathbf{A}) + \\mu(\\nabla\\times\\mathbf{A})]}_x\n\\end{align*}\n\nTherefore we have shown that,\n\n\\begin{align*}\n \\nabla\\times(\\lambda\\mathbf{A} + \\mu\\mathbf{B}) = \\lambda \\nabla\\times\\mathbf{A} + \\mu \\nabla\\times\\mathbf{B}\n\\end{align*}\n\nNext we have our fourth identity and our first product identity, from expression.~\\ref{eq:4},\n\n\\begin{align*}\n {[\\nabla(\\phi\\psi)]}_x &= \\frac{\\partial}{\\partial x}(\\phi\\psi) \\\\\n &= \\frac{\\partial \\phi}{\\partial x}\\psi + \\phi\\frac{\\partial\\psi}{\\partial x} \\\\\n &= {[\\nabla\\phi]}_x\\psi + \\phi{[\\nabla\\psi]}_x \\\\\n &= {[(\\nabla\\phi)\\psi + \\phi(\\nabla\\psi)]}_x\n\\end{align*}\n\nTherefore we have our fourth identity,\n\n\\begin{align*}\n \\nabla(\\phi\\psi) = (\\nabla\\phi)\\psi + \\phi(\\nabla\\psi)\n\\end{align*}\n\nNow for our fifth expression, which is a scalar so we have to prove for all components,\n\n\\begin{align*}\n \\nabla\\cdot(\\phi\\mathbf{A}) &= \\frac{\\partial}{\\partial x}{(\\phi\\mathbf{A})}_x + \\frac{\\partial}{\\partial y}{(\\phi\\mathbf{A})}_y + \\frac{\\partial}{\\partial z}{(\\phi\\mathbf{A})}_z \\\\\n &= \\frac{\\partial}{\\partial x}(\\phi A_x) + \\frac{\\partial}{\\partial y}(\\phi A_y) + \\frac{\\partial}{\\partial z}(\\phi A_z) \\\\\n &= \\frac{\\partial\\phi}{\\partial x} A_x + \\frac{\\partial\\phi}{\\partial y} A_y + \\frac{\\partial\\phi}{\\partial z} A_z + \\frac{\\partial A_x}{x} \\phi + \\frac{\\partial A_y}{y} \\phi + \\frac{\\partial A_z}{z} \\phi \\\\\n &= (\\nabla\\phi)\\cdot\\mathbf{A} + \\phi \\nabla\\cdot\\mathbf{A}\n\\end{align*}\n\nWe now have the fifth identity,\n\n\\begin{align*}\n \\nabla\\cdot(\\phi\\mathbf{A}) = (\\nabla\\phi)\\cdot\\mathbf{A} + \\phi \\nabla\\cdot\\mathbf{A}\n\\end{align*}\n\nFor our sixth expression, we have a vector and thus only have to prove one component,\n\n\\begin{align*}\n {[\\nabla\\times(\\phi\\mathbf{A})]}_x &= \\frac{\\partial}{\\partial y}{(\\phi\\mathbf{A})}_z - \\frac{\\partial}{\\partial z}{(\\phi\\mathbf{A})}_y \\\\\n &= \\frac{\\partial}{\\partial y}(\\phi A_z) - \\frac{\\partial}{\\partial z}(\\phi A_y) \\\\\n &= \\frac{\\partial\\phi}{\\partial y}A_z - \\frac{\\partial\\phi}{\\partial z}A_y + \\phi\\frac{\\partial A_z}{y} - \\phi\\frac{\\partial A_y}{z} \\\\\n &= {[\\nabla\\phi\\times\\mathbf{A}]}_x + {[\\phi\\nabla\\times\\mathbf{A}]}_x \\\\\n &= {[\\nabla\\phi\\times\\mathbf{A} + \\phi\\nabla\\times\\mathbf{A}]}_x\n\\end{align*}\n\nTherefore we have our sixth identity,\n\n\\begin{align*}\n \\nabla\\times(\\phi\\mathbf{A}) = (\\nabla\\phi)\\times\\mathbf{A} + \\phi(\\nabla\\times\\mathbf{A})\n\\end{align*}\n\nFor the rest of the proofs of the identities see canvas or written notes (the proofs are long and I cannot be bothered to type them up), but I will state all of the identities here,\n\n\\begin{align*}\n \\nabla(\\mathbf{A}\\cdot\\mathbf{B}) &= (\\mathbf{B}\\cdot\\mathbf{A})\\mathbf{A}+\\mathbf{B}\\times(\\nabla\\times\\mathbf{A})+(\\mathbf{A}\\cdot\\nabla)\\mathbf{B}+\\mathbf{A}\\times(\\nabla\\times\\mathbf{B}) \\\\\n \\nabla\\cdot(\\mathbf{A}\\times\\mathbf{B}) &= \\mathbf{B}\\cdot(\\nabla\\times\\mathbf{A}) - \\mathbf{A}\\cdot(\\nabla\\times\\mathbf{B}) \\\\\n \\nabla\\times(\\mathbf{A}\\times\\mathbf{B}) &= (\\mathbf{B}\\cdot\\nabla)\\mathbf{A}-(\\mathbf{A}\\cdot\\nabla)\\mathbf{B}+\\mathbf{A}(\\nabla\\cdot\\mathbf{B})-\\mathbf{B}(\\nabla\\cdot\\mathbf{A}) \\\\\n \\nabla\\cdot(\\nabla\\psi) &= \\nabla^2 \\psi \\\\\n \\nabla\\times(\\nabla\\psi) &= \\mathbf{0} \\\\\n \\nabla\\cdot(\\nabla\\times\\mathbf{A}) &= \\mathbf{0} \\\\\n \\nabla\\times(\\nabla\\times\\mathbf{A}) &= \\nabla(\\nabla\\cdot\\mathbf{A}) - \\nabla^2 \\mathbf{A}\n\\end{align*}\n\n\\section{Using Vector Calculus Identities: Maxwell's Equations and Continuity}\n\nFrom Coulomb's law, Biot Savart law, and Faraday's laws we can derive the differential form of Maxwell's equations,\n\n\\begin{alignat*}{2}\n \\nabla \\cdot \\mathbf{E} &= \\frac{\\rho}{\\epsilon_0} \\qquad &&\\nabla \\times \\mathbf{E} = -\\frac{\\partial\\mathbf{B}}{\\partial t} \\\\\n \\nabla \\cdot \\mathbf{B} &= 0 \\qquad &&\\nabla \\times \\mathbf{B} = \\mu_0 \\mathbf{J}\n\\end{alignat*}\n\nOur equation, $\\nabla\\times\\mathbf{B} = \\mu_0 \\mathbf{J}$, known as Ampere's circuital law is incomplete as it does not obey the continuity equation. The continuity equation describes that,\n\n\\begin{align*}\n \\frac{\\partial\\rho}{\\partial t} + \\nabla\\cdot\\mathbf{J} = 0\n\\end{align*}\n\nbut we see that if we take the divergence of $\\mathbf{J}$ we have zero,\n\n\\begin{align*}\n \\mu_0 \\nabla\\cdot\\mathbf{J} = \\nabla\\cdot(\\nabla\\times\\mathbf{B}) = 0.\n\\end{align*}\n\nby our identity that the divergence of a curl of a vector field is always zero. This implies that the rate of change of charge density, $\\frac{\\partial\\rho}{\\partial t}$ must always be equal to zero for the continuity equation to hold, but this is not necessary to be true for example with a current flowing through a wire. Therefore we must have that,\n\n\\begin{align*}\n \\nabla\\cdot\\mathbf{J} = -\\frac{\\partial\\rho}{\\partial t}\n\\end{align*}\n\nTherefore, by applying this,\n\n\\begin{align*}\n \\mu_0\\nabla\\cdot\\mathbf{J} = -\\mu_0\\frac{\\partial\\rho}{\\partial t} = -\\mu_0\\epsilon_0\\nabla\\cdot\\frac{\\partial\\mathbf{E}}{\\partial t}\n\\end{align*}\n\nHere we have recognised that the rate of change of charge density is given in the time derivative of Gauss' law. It follows that the continuity equation can be satisfied by writing,\n\n\\begin{align*}\n \\nabla\\times\\mathbf{B} = \\mu_0\\left(\\mathbf{J} + \\epsilon_0 \\frac{\\partial \\mathbf{E}}{\\partial t}\\right)\n\\end{align*}\n\nThis new term is called the displacement current, and this is known as Maxwell's addition to Ampere's circuit law.\n\n\\section{Using Vector Calculus Identities: Electromagnetic Wave Equation}\n\nMaxwell's equations in free space, that is space where there are no charges or currents reduce to,\n\n\\begin{alignat*}{2}\n \\nabla\\cdot\\mathbf{E} &= 0 \\qquad &&\\nabla\\times\\mathbf{E} = -\\frac{\\partial \\mathbf{B}}{\\partial t} \\\\\n \\nabla\\cdot\\mathbf{B} &= 0 \\qquad &&\\nabla\\times\\mathbf{B} = \\mu_0\\epsilon_0\\frac{\\partial\\mathbf{E}}{\\partial t}\n\\end{alignat*}\n\nTaking the curl of $\\nabla\\times\\mathbf{E}$ gives that,\n\n\\begin{align*}\n \\nabla\\times(\\nabla\\times\\mathbf{E}) = \\nabla\\times\\left(-\\frac{\\partial\\mathbf{B}}{\\partial t}\\right) = -\\frac{\\partial}{\\partial t} \\left(\\nabla\\times\\mathbf{B}\\right) = -\\mu_0\\epsilon_0\\frac{\\partial^2\\mathbf{E}}{\\partial t^2}\n\\end{align*}\n\nTherefore we have using our vector identity for the curl of a curl of a vector field,\n\n\\begin{align*}\n \\nabla(\\nabla\\cdot\\mathbf{E}) - \\nabla^2 \\mathbf{E} = -\\mu_0\\epsilon_0\\frac{\\partial^2\\mathbf{E}}{\\partial t^2}\n\\end{align*}\n\nFrom our free space version of Gauss' law we can see that the first term goes to zero, so that\n\n\\begin{align*}\n \\nabla^2\\mathbf{E} = \\mu_0\\epsilon_0\\frac{\\partial^2\\mathbf{E}}{\\partial t^2}\n\\end{align*}\n\nThis is just the wave equation, just as in classical wave theory. The only difference between this and how we remember the wave equation from the first year is that instead of taking the second derivative with respect to position in one direction, we now take the second derivative in all directions, which is just the Laplacian. We therefore see that $\\mathbf{E}$ satisfies the wave equation with velocity $c = \\frac{1}{\\sqrt{\\mu_0\\epsilon_0}}$.\n\nWe can do the same thing with the $\\mathbf{B}$-field by computing $\\nabla\\times(\\nabla\\times\\mathbf{B})$,\n\n\\begin{align*}\n \\nabla\\times(\\nabla\\times\\mathbf{B}) &= \\mu_0\\epsilon_0\\frac{\\partial}{\\partial t}(\\nabla\\times\\mathbf{E}) \\\\\n \\nabla(\\nabla\\cdot\\mathbf{B}) - \\nabla^2\\mathbf{B} &= \\mu_0\\epsilon_0\\frac{\\partial}{\\partial t}\\left(-\\frac{\\partial\\mathbf{B}}{\\partial t}\\right)\n\\end{align*}\n\nHere we have used that $\\nabla\\times\\mathbf{E} = -\\frac{\\partial\\mathbf{B}}{\\partial t}$. Again we can say that the first term $\\nabla(\\nabla\\cdot\\mathbf{B})$ is zero as Gauss' law for magnetism tells us, so finally we have,\n\n\\begin{align*}\n \\nabla^2\\mathbf{B} = \\mu_0\\epsilon_0\\frac{\\partial^2\\mathbf{B}}{\\partial t^2}\n\\end{align*}\n\nWhich is again the same form of the wave equation satisfied by the electric field. We therefore see that we now have two fields, the magnetic field and the electric field, which both satisfy the classical wave equation of the same form.\n\n\n\n\\end{document}\n", "meta": {"hexsha": "dbbf1f1622fb60472388ee8002ee78063a18cca9", "size": 25070, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "maths/vectorcalc/vectorcalc.tex", "max_stars_repo_name": "unanimousarc/physics", "max_stars_repo_head_hexsha": "7bc9cbd428defb7615f5a2e241d86fae71ece7b3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-13T14:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-06T14:27:57.000Z", "max_issues_repo_path": "maths/vectorcalc/vectorcalc.tex", "max_issues_repo_name": "unanimousarc/physics", "max_issues_repo_head_hexsha": "7bc9cbd428defb7615f5a2e241d86fae71ece7b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "maths/vectorcalc/vectorcalc.tex", "max_forks_repo_name": "unanimousarc/physics", "max_forks_repo_head_hexsha": "7bc9cbd428defb7615f5a2e241d86fae71ece7b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-29T08:14:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-29T08:14:51.000Z", "avg_line_length": 52.0124481328, "max_line_length": 575, "alphanum_fraction": 0.6502193857, "num_tokens": 8427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480252950991, "lm_q2_score": 0.9173026601509101, "lm_q1q2_score": 0.8425243793280248}} {"text": "\\section*{Exercises}\n\n\\begin{ex} Show that $1+i,2+i$ are the only two roots to\n\\begin{equation*}\np(x) =x^{2}-(3+2i) x+(1+3i)\n\\end{equation*}\nHence complex zeros do not necessarily come in conjugate pairs if the coefficients of the equation\nare not real.\n\\begin{sol}\n\\[\n(x-(1+i)) (x-(2+i))\n= x^{2}-(3+2i) x+1+3i\n\\]\n\\end{sol}\n\\end{ex}\n\n\\begin{ex} Give the solutions to the following quadratic equations having real\ncoefficients.\n\n\\begin{enumerate}\n\\item $x^{2}-2x+2=0$\n\n\\item $3x^{2}+x+3=0$\n\n\\item $x^{2}-6x+13=0$\n\n\\item $x^{2}+4x+9=0$\n\n\\item $4x^{2}+4x+5=0$\n\\end{enumerate}\n\\begin{sol}\n\\begin{enumerate}\n\\item Solution is: $1+i,1-i$\n\\item Solution is: $\\frac{1}{6}i\\sqrt{35}-\\frac{1}{6},-\\frac{%\n1}{6}i\\sqrt{35}-\\frac{1}{6}$\n\\item Solution is: $3+2i,3-2i$\n\\item Solution is: $i\\sqrt{5}-2,-i\\sqrt{5}-2$\n\\item Solution is: $-\\frac{1}{2}+i,-\\frac{1}{2}-i$\n\\end{enumerate}\n\\end{sol}\n\\end{ex}\n\n\\begin{ex} Give the solutions to the following quadratic equations having complex\ncoefficients.\n\n\\begin{enumerate}\n\\item $x^{2}+2x+1+i=0$\n\n\\item $4x^{2}+4ix-5=0$\n\n\\item $4x^{2}+(4+4i) x+1+2i=0$\n\n\\item $x^{2}-4ix-5=0$\n\n\\item $3x^{2}+(1-i) x+3i=0$\n\\end{enumerate}\n\\begin{sol}\n\\begin{enumerate}\n\\item Solution is : $x=-1+\\frac{1}{2}\\sqrt{2}-\\frac{1}{2}i\n\\sqrt{2},\\;\\;x=-1-\\frac{1}{2}\\sqrt{2}+\\frac{1}{2}i\\sqrt{2}$\n\\item Solution is : $x=1-\\frac{1}{2}i,\\;x=-1-\\frac{1}{2}i$\n\\item Solution is : $x=-\\frac{1}{2},\\;x=-\\frac{1}{2}-i$\n\\item Solution is : $x=-1+2i,\\;\\;x=1+2i$\n\\item Solution is : $x=-\\frac{1}{6}+\\frac{1}{6}\\sqrt{19}+\\paren{\\frac{1}{6}-\\frac{1}{6}\\sqrt{19}} i,\\;\\;x=-\\frac{1}{6}-\\frac{1}{6}\\sqrt{19}+\\paren{\\frac{1}{6}+\\frac{1}{6}\\sqrt{19}}i$\n\\end{enumerate}\n\\end{sol}\n\\end{ex}\n\n\\begin{ex} \\label{exer-complex3}Prove the fundamental theorem of algebra for\nquadratic polynomials having coefficients in $\\C$. That is, show\nthat an equation of the form \\\\ $ax^{2}+bx+c=0$ where $a,b,c$ are complex\nnumbers, $a\\neq 0$ has a complex solution. \\textbf{Hint: }Consider the fact,\nnoted earlier that the expressions given from the quadratic formula do in\nfact serve as solutions.\n%\\begin{sol}\n%\\end{sol}\n\\end{ex}\n\n", "meta": {"hexsha": "a98cc81b169cc2533f25be5d34fd5b7415fb889b", "size": 2100, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "old/exercises/ComplexNumbers-Quadratic.tex", "max_stars_repo_name": "selinger/linear-algebra", "max_stars_repo_head_hexsha": "37ad955fd37bdbc6a9e855c3794e92eaaa2d8c02", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2019-03-21T06:37:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T16:23:10.000Z", "max_issues_repo_path": "old/exercises/ComplexNumbers-Quadratic.tex", "max_issues_repo_name": "selinger/linear-algebra", "max_issues_repo_head_hexsha": "37ad955fd37bdbc6a9e855c3794e92eaaa2d8c02", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/exercises/ComplexNumbers-Quadratic.tex", "max_forks_repo_name": "selinger/linear-algebra", "max_forks_repo_head_hexsha": "37ad955fd37bdbc6a9e855c3794e92eaaa2d8c02", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2020-11-09T11:12:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-30T16:23:12.000Z", "avg_line_length": 26.582278481, "max_line_length": 182, "alphanum_fraction": 0.6385714286, "num_tokens": 889, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026663679976, "lm_q2_score": 0.9184802434674242, "lm_q1q2_score": 0.8425243763389958}} {"text": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% CS624: Analysis of Algorithms\n% Copyright 2015 Pejman Ghorbanzade \n% Creative Commons Attribution-ShareAlike 4.0 International License\n% More info: https://github.com/ghorbanzade/beacon\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section*{Question 2}\n\nShow that the second smallest of $n$ elements can be found with $n + \\lceil \\log n \\rceil - 2$ comparisons in the worst case.\n\n\\subsection*{Solution}\n\nWe begin by comparing elements of the array two by two, each time putting the minimum number in a new array of size $\\lceil \\frac{n}{2} \\rceil$.\nWe will repeat the procedure for the new array until our new array will have only one element which is the element with minimum value.\nTo calculate the number of comparisons it takes to find the element with minimum value, we use the analogy of a tree with $n$ nodes at height $H$, in which case the number of comparisons would be equal to number of nodes at levels greater than $0$ which is $n - 1$.\n\nThe second smallest element is the smallest of all other nodes except the root.\nTherefore, there has been a comparison in which this element has lost to the element with minimum value.\nAs the latter is compared $\\lceil \\log n \\rceil$ times, we can compare all its losers to eachother to obtain the second smallest element, a procedure which takes $\\lceil \\log n \\rceil - 1$ comparisons.\n\nTherefore the total number of comparisons would be $n + \\lceil \\log n - 2$.\n", "meta": {"hexsha": "08df56585c7f0ed069a4018ce89beb7f0ea35d57", "size": 1540, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "umb-cs624-2015s/src/tex/hw03/hw03q02.tex", "max_stars_repo_name": "ghorbanzade/beacon", "max_stars_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-11-13T20:00:10.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-01T11:16:51.000Z", "max_issues_repo_path": "umb-cs624-2015s/src/tex/hw03/hw03q02.tex", "max_issues_repo_name": "ghorbanzade/beacon", "max_issues_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "umb-cs624-2015s/src/tex/hw03/hw03q02.tex", "max_forks_repo_name": "ghorbanzade/beacon", "max_forks_repo_head_hexsha": "c36e3d1909b9e1e47b1ad3cda81f7f33b713adc4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-09-20T05:58:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-06T17:18:05.000Z", "avg_line_length": 66.9565217391, "max_line_length": 265, "alphanum_fraction": 0.6967532468, "num_tokens": 358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122163480666, "lm_q2_score": 0.9284087936225136, "lm_q1q2_score": 0.8423566402186775}} {"text": "\\section*{Ex.2.6}\n\\subsection*{Multiply-mod-prime hash function where $a=0$ is possible}\n\n\\emph{Show it is not universal.}\n\nTo be a universal hash function it must hold that for all distinct keys $P(h(x)=h(y))\\leq 1/m$.\n\nWe will give a concrete example where the above probability is not fulfilled:\n\\\\\nSet $p=3$, $m=2$, $x=0$, $y=1$. Then the possible values for $a,b\\in\\{0,1,2\\}$. The table below shows the hash value for $x$ and $y$ with the value set above.\n\n\\begin{center}\n\\begin{tabular}{l|cc|r}\n & $h(x)$ & $h(y)$ & collision\\\\\n\\hline\n $(a,b)=(0,0)$& 0 & 0 & true\\\\\n $(a,b)=(0,1)$& 1 & 1 & true\\\\\n $(a,b)=(0,2)$& 0 & 0 & true\\\\\n $(a,b)=(1,0)$& 0 & 1 & false\\\\\n $(a,b)=(1,1)$& 1 & 0 & false\\\\\n $(a,b)=(1,2)$& 0 & 0 & true\\\\\n $(a,b)=(2,0)$& 0 & 0 & true\\\\\n $(a,b)=(2,1)$& 1 & 0 & false\\\\\n $(a,b)=(2,2)$& 0 & 1 & false\n\\end{tabular}\t\n\\end{center}\n\nIt can be seen that for 5 out of the 9 possibilities, there is a collision. Hence the probability for collision is\n$$\nP(h(0)=h(1)) = \\frac{5}{9} > \\frac{1}{2} = \\frac{1}{m}\n$$\nSo we have found an instance where this hash function is not universal.\n\n\\emph{Prove that it is always 2-universal}\n\nFirst note that for $a=0$, then $P(h_{0,b}(x)=h_{0,b}(y)) = 1$ for all values of $b, x, y$. The probability $P(a=0)=1/p$. To prove 2-universal we see that\n\\begin{align*}\nP(h_{a,b}(x) = h_{a,b}(y)) &= P([(a=0)\\cap(h_{a,b}(x) = h_{a,b}(y))]\\cup [(a>0)\\cap(h_{a,b}(x) = h_{a,b}(y))])\\\\\n&= P((a=0)\\cap(h_{0,b}(x) = h_{0,b}(y))) + P((a>0)\\cap(h_{a,b}(x) = h_{a,b}(y)))\\\\\n&= \\frac{1}{p} + P((a>0)\\cap(h_{a,b}(x) = h_{a,b}(y))) \\\\\n&< \\frac{1}{p} + \\frac{1}{m} \\\\\n&< \\frac{1}{m} + \\frac{1}{m} \\\\\n&= \\frac{2}{m}\n\\end{align*}\nHence we have shown that the hash function is 2-universal.", "meta": {"hexsha": "90af8407c97184bdf8db328590d7a5a3604ea8d2", "size": 1731, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Uge3/Ex.2.6.tex", "max_stars_repo_name": "pdebesc/AADS", "max_stars_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Uge3/Ex.2.6.tex", "max_issues_repo_name": "pdebesc/AADS", "max_issues_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Uge3/Ex.2.6.tex", "max_forks_repo_name": "pdebesc/AADS", "max_forks_repo_head_hexsha": "a26e24d18adee973d3ce88bdfd96d857ec472fdf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.4666666667, "max_line_length": 158, "alphanum_fraction": 0.5632582322, "num_tokens": 730, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391685381605, "lm_q2_score": 0.9124361598816666, "lm_q1q2_score": 0.8422143143613255}} {"text": "\n\\subsection{Modelling non-linear functions as linear}\n\n\\subsubsection{Polynomials}\n\nThe function \\(y=x^2\\) is not linear, however we can model is as linear, by including \\(x^2\\) as a variable.\n\nWe can expand this, and using linear models to estimate parameters for functions such as:\n\n\\(y=ax^3+bx^2+xz\\)\n\n\\subsubsection{Logarithms and exponentials}\n\nWe can also transform data using logarithms and exponents.\n\nFor example we can model\n\n\\(\\ln y=\\theta \\ln x\\)\n\n", "meta": {"hexsha": "33076ab73550e02bb06c3ded56825ecb76a88d17", "size": 461, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/statistics/ols/01-03-nonLinear.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/statistics/ols/01-03-nonLinear.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/statistics/ols/01-03-nonLinear.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.05, "max_line_length": 108, "alphanum_fraction": 0.748373102, "num_tokens": 120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9669140225647107, "lm_q2_score": 0.8705972717658209, "lm_q1q2_score": 0.8417927100769526}} {"text": "\n\\subsection{Empty set}\n\nWe can use this to define the empty set - the set with no members.\n\n\\(\\varnothing =\\{\\}\\)\n\nUsing the above definition this is the same as writing:\n\n\\(\\forall x \\neg (x\\in \\varnothing )\\)\n\n\n", "meta": {"hexsha": "616efcc8af010b5fddabe7b658c97f5441a6dabd", "size": 214, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/logic/setsSpecification/01-04-empty.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/logic/setsSpecification/01-04-empty.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/logic/setsSpecification/01-04-empty.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.4615384615, "max_line_length": 66, "alphanum_fraction": 0.6822429907, "num_tokens": 59, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9669140235181257, "lm_q2_score": 0.8705972616934406, "lm_q1q2_score": 0.8417927011678673}} {"text": "\\section{Smoothing and Penalized Least Squares }\nIn Section 4.4.1 we saw that the smoothing spline solution to a\npenalized least squares is a linear smoother.\n\nUsing the notation of Section 4.4.1, we can write the penalized\ncriterion as \n\\[\n(\\by - \\bB\\bg{\\theta})'(\\by - \\bB\\bg{\\theta}) +\n\\lambda\\bg{\\theta}'\\bg{\\Omega}\\bg{\\theta}\n\\]\n\nSetting derivatives with respect to $\\bg{\\theta}$ equal to 0 gives\nthe estimating equation:\n\\[\n(\\bB'\\bB + \\lambda\\bg{\\Omega})\\bg{\\theta} = \\bB'\\by\n\\]\nthe $\\hat{\\bg{\\theta}}$ that solves this equation will give us the\nestimate $\\hat{\\g} = \\bB \\hat{\\bg{\\theta}}$.\n\n\nWrite:\n\\[\n\\hat{\\g} = \\bB \\bg{\\theta} = \\bB(\\bB'\\bB + \\lambda \\bg{\\Omega})^{-1}\n\\bB'\\by = ({\\mathbf I} + \\lambda {\\mathbf K})^{-1}\\by\n\\]\nwhere ${\\mathbf K} = \\bB'^{-} \\bg{\\Omega} \\bB^{-}$. \n\nNotice we can\nwrite the penalized criterion as\n\\[\n(\\by - \\g)'(\\by - \\g) + \\lambda \\g' {\\mathbf K} \\g\n\\]\n\nIf we plot the rows of this linear smoother we will see that it is\nlike a kernel smoother.\n\n\n\n\\begin{figure}[htb]\n\\caption{Kernels of a smoothing spline.}\n\\begin{center}\n\\epsfig{figure=Plots/plot-06-03.ps,angle=270,width=\\textwidth}\n\\end{center}\n\\end{figure}\n\nNotice that for any linear smoother with a symmetric and nonnegative\ndefinite $\\bS$, i.e. there $\\bS^{-}$ exists, then \nwe can argue in reverse: $\\hat{\\f}=\\bS\\by$ is the value that minimizes the\npenalized least squares criteria of the form\n\\[\n(\\by - \\f)'(\\by - \\f) + \\f'(\\bS^{-} - I)\\f.\n\\]\n\nSome of the smoothers presented in this class are not symmetrical but\nare close. In fact for many of them one can show that asymptotically\nthey are symmetric.\n\n\n\n\n", "meta": {"hexsha": "a8ffda97187ccc2ac91b182a46c1432e31f838d0", "size": 1610, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "pages/754/section-06-02.tex", "max_stars_repo_name": "igrabski/rafalab.github.io", "max_stars_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2016-08-17T23:04:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T19:21:02.000Z", "max_issues_repo_path": "pages/754/section-06-02.tex", "max_issues_repo_name": "igrabski/rafalab.github.io", "max_issues_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2016-08-18T00:41:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-21T22:35:40.000Z", "max_forks_repo_path": "pages/754/section-06-02.tex", "max_forks_repo_name": "igrabski/rafalab.github.io", "max_forks_repo_head_hexsha": "2f27ea0d9e0b8a2342bb851ae7415ba3268fd00f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 38, "max_forks_repo_forks_event_min_datetime": "2016-08-17T22:17:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-20T12:17:08.000Z", "avg_line_length": 26.393442623, "max_line_length": 74, "alphanum_fraction": 0.6652173913, "num_tokens": 541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951661947456, "lm_q2_score": 0.9005297841157157, "lm_q1q2_score": 0.8414506772921225}} {"text": "\\section{Non-Parametric Estimation of the CDF and Statistical Functionals}\n\n\\subsection{Empirical Distribution Function}\nIt may be necessary to perform non-parametric estimation of the CDF $F$ of a set of random variables $X_1, X_2, ... , X_n \\sim F$. \n\nThe empirical distribution function $\\hat{F}_n$ is the CDF that puts mass $1/n$ at each point $X_i$.\n\n\\begin{equation}\n\\hat{F}_n(x) = \\frac{\\sum_{i=1}^n I(X_i \\leq x)}{n}\n\\end{equation}\n\nWhere $I(X_i \\leq x) = \\left\\{\\begin{array}{c} 1\\ \\mathrm{if\\ } X_i \\leq x\\\\ 0\\ \\mathrm{if\\ } X_i > x \\end{array} \\right.$. \n\nThe empirical CDF is discrete, even when the random variable it is based on may be continuous. \n\nAt a given point $x$, $\\hat{F}_n(x)$ is an unbiased estimator of $F(x)$. \n\n\\begin{itemize}\n\\item $\\mathbb{E}\\hat{F}_n(x) = F(x)$\n\\item $\\mathbb{V}\\hat{F}_n(x) = 0+\\mathrm{MSE} = \\frac{F(x)(1-F(x))}{n}$\n\\item $\\hat{F}_n(x) \\xrightarrow{P} F(x)$\n\\end{itemize}\n\nThe Glivenko-Cantelli Theorem guarantees that, if $X_1,X_2,...,X_n \\sim F$, then:\n\n\\begin{equation}\n\\sup_x |\\hat{F}_n(x) - F(x)|\\xrightarrow{P} 0\n\\end{equation}\n\n\\subsection{Confidence Measures for the Empirical CDF}\nA confidence interval for the empirical CDF is given through the Dvoretzky-Kiefer-Wolfowitz (DKW) Inequality:\n\n\\begin{equation}\n\\mathbb{P}\\left(\\sup_x|F(x) - \\hat{F}_n(x)|>\\epsilon \\right)\\leq 2 e^{-2n\\epsilon^2}\n\\end{equation}\n\nA nonparametric $1-\\alpha$ confidence band is then:\n\n\\begin{equation}\n\\begin{array}{c}\nL(x) = \\max\\{\\hat{F}_n -\\epsilon_n, 0 \\}\\\\\n\\\\\nU(x) = \\min\\{\\hat{F}_n + \\epsilon_n, 1\\}\n\\end{array}\n\\end{equation}\n\nwith $\\epsilon_n = \\sqrt{\\frac{1}{2n}\\log\\left(\\frac{2}{\\alpha}\\right)}$.\n\n\\begin{equation}\n\\mathbb{P}\\left(L(x) \\leq F(x) \\leq U(x) \\right) \\geq 1-\\alpha\n\\end{equation}\n\t\n\n\n\\subsection{Statistical Functionals}\nA functional is, roughly speaking, a function of a function. The fourier transform of a function is a functional. A \\textit{statistical functional} is any function of the CDF, $F$. Examples are the mean, the variance, or the median. \n\n\\subsection{Plug-in Estimator}\nThe plug-in estimator of $\\theta = T(F)$ is given by $\\hat{\\theta} = T(\\hat{F}_n)$. In other words, the estimate of the CDF is used instead of the true $F$, resulting in an estimator.\n\n\\subsection{Linear Functionals}\nFunctionals of the form $T(F) = \\int r(x) dF(x)$ are linear functionals. \n\n\\subsection{Plug-in Estimator for Linear Functionals}\n\\begin{equation}\nT(\\hat{F}_n) = \\int r(x) d\\hat{F}_n(x) = \\frac{1}{n}\\sum^{n}_{i=1}r(X_i)\n\\end{equation}\n\n\\subsection{Examples: Mean, Variance, Sample Variance, Sample Correlation}\n\\citeasnoun{wasserman2013all} pp. 100\n", "meta": {"hexsha": "8a09ede0ac4149965eac85c64b232e920601f611", "size": 2614, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "notes/chapters/sections/stats_functionals.tex", "max_stars_repo_name": "jpbm/probabilism", "max_stars_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/chapters/sections/stats_functionals.tex", "max_issues_repo_name": "jpbm/probabilism", "max_issues_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/chapters/sections/stats_functionals.tex", "max_forks_repo_name": "jpbm/probabilism", "max_forks_repo_head_hexsha": "a2f5c1595aed616236b2b889195604f365175899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.8169014085, "max_line_length": 233, "alphanum_fraction": 0.6931905126, "num_tokens": 920, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632996617212, "lm_q2_score": 0.907312219480915, "lm_q1q2_score": 0.8414080536812211}} {"text": "\\section{Limit Definition}\r\n\\begin{definition}\r\n\tLet $f : D \\subseteq \\R \\to \\R$.\r\n\tLet $c \\in R$ be a limit point (ie $c \\in D$ or $c$ is on the boundary of $D$).\r\n\t$f$ has a limit $L$ as $x$ approaches $c$ if for any given positive real number $\\epsilon$, there is a positive real number $\\delta$ such that for all $x \\in D$,\r\n\t\\begin{equation}\r\n\t\t0 < \\abs{x-c} < \\delta \\implies \\abs{f(x) - L} < \\epsilon.\r\n\t\\end{equation}\r\n\tWe write this as\r\n\t\\begin{equation*}\r\n\t\t\\lim_{x \\to c}{f(x)} = L.\r\n\t\\end{equation*}\r\n\\end{definition}\r\n\r\n\\begin{figure}[H]\r\n\t\\label{epsilon_delta}\r\n\t\\centering\r\n\t\\includegraphics[width = 0.5\\textwidth]{./limits_continuity/limit_epsilon_delta.png}\r\n\t\\caption{\\hyperref{https://en.wikipedia.org/wiki/(\\%CE\\%B5,\\_\\%CE\\%B4)-definition\\_of\\_limit}{}{}{Wikipedia - $(\\epsilon, \\delta)\\text{-definition of limit}$}}\r\n\\end{figure}\r\n\r\nVisually, what this means is that for any ``error bound'' of $y$ values $\\epsilon$, I can give you a corresponding error bound of $x$ values $\\delta$ such that all values of $f(z)$ for $z \\in (c -\\delta, c+ \\delta)$ bound are between $L - \\epsilon$ and $L + \\epsilon$.\r\n\r\n\r\nWe don't use this definition of the limit very often because it's a bit cumbersome.\r\nHowever, it's important to know that when we use the limit, this is the formal definition making things work.\r\n\r\n\\begin{example}\r\n\tUse the $(\\epsilon, \\delta)$ definition of the limit to show that\r\n\t\\begin{equation*}\r\n\t\t\\lim_{x\\to 0}{x\\sin{\\frac{1}{x}}} = 0.\r\n\t\\end{equation*}\r\n\\end{example}\r\n\\begin{answer}\r\n\tLetting $\\epsilon > 0$, we need to find corresponding $\\delta > 0$ that satisfies the definition for $L = 0$.\r\n\tKnowing that $\\sin$ is bounded between -1 and 1,\r\n\t\\begin{equation*}\r\n\t\t\\abs{x\\sin{\\frac{1}{x}} - 0} = \\abs{x\\sin{\\frac{1}{x}}} = \\abs{x}\\abs{\\sin{\\frac{1}{x}}} \\leq \\abs{x}.\r\n\t\\end{equation*}\r\n\t\r\n\tLetting $\\delta = \\epsilon$, if $0 < \\abs{x - 0} < \\delta$, then $\\abs{x\\sin{\\frac{1}{x}} - 0} \\leq \\abs{x} < \\epsilon$, as required by the definition.\r\n\\end{answer}", "meta": {"hexsha": "1fa0d9577de8cc515ab36c3b6271642365fa6fc1", "size": 1998, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/limits_continuity/limit_definition.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/limits_continuity/limit_definition.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/limits_continuity/limit_definition.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 47.5714285714, "max_line_length": 269, "alphanum_fraction": 0.6491491491, "num_tokens": 673, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966686936261, "lm_q2_score": 0.8887587927558434, "lm_q1q2_score": 0.8412961124948501}} {"text": "\n\\subsection{Limit points and closure}\n\n\\subsubsection{Limit points}\n\nA point \\(x\\) in the topological set \\(X\\) is a limit point for \\(S\\subset X\\) if every neighbourhood of \\(x\\) contains another point in \\(S\\).\n\nFor example \\(-1\\) is a limit point for the real numbers where \\(S\\) is \\([0,1]\\) (or \\((0,1)\\).\n\n\\subsubsection{Closure}\n\nThe closure of a subset of a topological space is the subset itself along with all limit points.\n\nSo the closure of \\(|x|<1\\) includes \\(-1\\) and \\(1\\).\n\n", "meta": {"hexsha": "27f97354f35009fedbd35e83759c2c8b2740f873", "size": 492, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/geometry/topologyFinite/02-01-closure.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/geometry/topologyFinite/02-01-closure.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/geometry/topologyFinite/02-01-closure.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.75, "max_line_length": 143, "alphanum_fraction": 0.6788617886, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750400464604, "lm_q2_score": 0.8824278710924295, "lm_q1q2_score": 0.8411964641537485}} {"text": "% !TeX root = ../main.tex\n% Add the above to each chapter to make compiling the PDF easier in some editors.\n\n\\chapter{Groups and Homomorphisms}\n\\section{Groups}\n\\begin{defn}[Semigroup, Monoid, and Group]\\leavevmode\n\\begin{defnlist}\n \\item A set $G$ with a mapping $\\cdot$ on $G$ (that is, $\\cdot: G \\times G \\to G$) is named \\begin{itemize}\n \\item \\emph{semigroup}\\index{semigroup} if $\\forall a, b, c \\in G.\\ (a \\cdot b) \\cdot c = a \\cdot (b \\cdot c)$; \\margintag{\\emph{associativity}\\index{associativity}}\n \\item \\mbox{\\emph{monoid}\\index{monoid} if it is a semigroup and $\\exists e \\in G.\\ \\forall a \\in G.\\ e \\cdot a = a \\cdot e = a$; \\margintag{$e$ is called \\emph{neutral element}\\index{neutral element}}}\n \\item \\emph{group}\\index{group} if it is a monoid and $\\forall a \\in G.\\ \\exists a' \\in G.\\ a \\cdot a' = a' \\cdot a = e$. \\margintag{$a'$ is the \\emph{inverse element}\\index{inverse element} of $a$}\n \\end{itemize}\n \n \\item A group $(G,\\cdot)$ is named \\emph{abelian}\\index{abelian group} or \\emph{commutative}\\index{commutativity} if the group operation $\\cdot$ is commutative under elements of $G$, \\begin{align}\n \\forall a, b \\in G.\\quad a \\cdot b = b \\cdot a.\n \\end{align}\n \n \\begin{marginfigure}\n We denote groups by $(G,\\cdot)$. If the group operation $\\cdot$ is clear from context, we refer to the group simply as $G$. Subsequently, we also write $a b$ instead of $a \\cdot b$.\n \\end{marginfigure}\n\\end{defnlist}\n\\end{defn}\n\n\\begin{rmk}\nLet $G$ be a group. Then, \\begin{rmklist}\n \\item there is exactly one neutral element $e \\in G$ and for every $a \\in G$ there is exactly one inverse element $a' \\in G$, which we call $\\inv{a}$;\n \\item the mapping on $G$, which we refer to by $\\cdot$, may be resembled by any symbol;\n \\item if $G$ is abelian, often \\begin{itemize}\n \\item $+$ is used instead of $\\cdot$,\n \\item $0$ is used instead of $e$, and\n \\item $-a$ is used instead of $\\inv{a}$.\n \\end{itemize}\n\\end{rmklist}\n\\end{rmk}\n\n\\begin{ex}{Semigroups, monoids, and groups}{}\n\\begin{center}\n\\setlength\\tabcolsep{5pt}\n\\begin{tabular}{lrrrrr}\n\\toprule\n & $(\\NO,+)$ & $(\\NZ,+)$ & $(\\Z,+)$ & $(\\Z,\\cdot)$ & $(\\woZ{\\Q},\\cdot)$ \\\\\n \\midrule\n semigroup & yes & yes & yes & yes & yes \\\\\n \\addlinespace\n monoid & no & yes & yes & yes & yes \\\\\n \\addlinespace\n group & yes & no & yes & no & yes \\\\\n \\bottomrule\n\\end{tabular}\n\\end{center}\n\\end{ex}\n\n\\begin{ex}{General linear and special linear group}{}\nThe \\emph{general linear group}\\index{general linear group} $\\GL{n}{K}$ is the group of invertible\\marginfootnote{Recall from linear algebra that a matrix $\\mA$ is invertible iff $\\det{\\mA} \\neq 0$.} ${n \\times n}$ linear maps over a field\\marginfootnote[1\\baselineskip]{A \\emph{field}\\index{field} is a set of elements with well-defined operations for addition, subtraction, multiplication, and division. We give a formal definition in \\cref{defn:field}. Examples of fields are the rational numbers $\\Q$, the real numbers $\\R$, and the complex numbers $\\C$.} $K$, \\begin{align}\n \\GL{n}{K} \\defeq \\{\\mA \\in K^{n \\times n} \\mid \\det{\\mA} \\neq 0\\}.\n\\end{align}\n\nThe \\emph{special linear group}\\index{special linear group} $\\SL{n}{K}$ is the group of normed linear maps over the field $K$, \\begin{align}\n \\SL{n}{K} \\defeq \\{\\mA \\in K^{n \\times n} \\mid \\det{\\mA} = 1\\}.\n\\end{align}\n\nThe group operation of $\\GL{n}{K}$ and $\\SL{n}{K}$ is matrix multiplication. Their neutral element is the identity matrix $\\mI$, and the inverse elements are the matrix inverses $\\inv{\\mA}$.\n\\end{ex}\n\n\\begin{ex}{Abelian groups}{}\n\\begin{itemize}\n \\item $(\\Z,+)$\n \\item $(\\Q,+)$\n \\item $(\\R,+)$\n \\item $(\\woZ{\\R},\\cdot)$\n\\end{itemize}\n\\end{ex}\n\n\\begin{ex}{Symmetric group}{}\nThe \\emph{symmetric group}\\index{symmetric group} $S_n$ is the group of bijections on the set $[n]$, \\begin{align}\n S_n \\defeq \\{\\sigma : [n] \\to [n] \\mid \\text{$\\sigma$ is bijective}\\},\n\\end{align} with the function composition ``$\\circ$'' as mapping.\n\nElements of the symmetric group ${\\sigma \\in S_n}$ are called \\emph{permutations}\\index{permutation}. The neutral element of the symmetric group is the identity $\\id$, which maps each input to itself.\n\nThere are multiple ways of representing permutations. Perhaps the most natural representation of ${\\sigma \\in S_n}$ is a mapping in \\emph{two-line notation}\\index{two-line notation}, \\begin{align}\n \\sigma = \\begin{pmatrix}\n 1 & 2 & \\cdots & n \\\\\n \\sigma(1) & \\sigma(2) & \\cdots & \\sigma(n) \\\\\n \\end{pmatrix},\n\\end{align} or in \\emph{one-line notation}\\index{one-line notation} by simply omitting the first line, \\begin{align}\n \\sigma = (\\sigma(1)\\ \\sigma(2)\\ \\cdots\\ \\sigma(n)).\n\\end{align}\n\nAn alternative characterization of a permutation is as a product of (disjoint) cycles. A \\emph{cycle}\\index{cycle} ${\\rho \\in S_n}$ is a permutation that maps a subset of numbers ${\\{i_1, i_2, \\dots, i_r\\} \\subseteq [n]}$ in a cyclic fashion. That is, \\begin{align}\n \\rho(i_1) = i_2,\\quad \\rho(i_2) = i_3,\\quad \\cdots\\quad \\rho(i_{r-1}) = i_r,\\quad \\rho(i_r) = i_1,\n\\end{align} leaving all other ${j \\in [n]}$ fixed. We denote such a cycle by \\begin{align}\n \\rho = (i_1\\ i_2\\ \\cdots\\ i_r).\n\\end{align} A cycle of length $r$, is also called \\emph{$r$-cycle}. 2-cycles are called \\emph{transpositions}\\index{transposition}.\n\nEvery permutation ${\\sigma \\in S_n}$ can be written as a ``product'' (i.e., composition), \\begin{align}\n \\sigma = \\rho_1 \\cdots \\rho_s,\n\\end{align} where $\\rho_i$ are cycles with pairwise disjunct elements. This is also known as the \\emph{cycle notation}\\index{cycle notation} of $\\sigma$. Note that the ordering of $\\rho_1, \\dots \\rho_s$ does not matter, as their elements are disjoint.\n\nThe cycle lengths $r_1, \\dots, r_s$ (in descending order) of $\\rho_1, \\dots, \\rho_s$ are the \\emph{cycle type}\\index{cycle type} of $\\sigma$.\n\n\\begin{rmk}\nThe symmetric group is not abelian.\n\\end{rmk}\\vspace{-20pt}\\begin{proof}\nWe have $(1\\ 2)(2\\ 3) = (2\\ 3\\ 1)$ and $(2\\ 3)(1\\ 2) = (1\\ 3\\ 2)$.\n\\end{proof}\n\\end{ex}\n\n\\begin{lem}[Notation and Rules]\nLet $(G,\\cdot)$ be a group. \\begin{lemlist}\n \\item For $a \\in G, n \\in \\NZ$, we write \\begin{itemize}\n \\item $a^n \\defeq \\underbrace{a \\cdot a \\cdots a}_{\\text{$n$ many}}$,\n \\item $a^0 \\defeq e$, and\n \\item $a^{-n} \\defeq \\underbrace{\\inv{a} \\cdot \\inv{a} \\cdots \\inv{a}}_{\\text{$n$ many}}$.\n \\end{itemize}\n \n \\item $\\forall a, b \\in G.\\ \\forall m, n \\in \\Z.$ \\begin{nestedlemlist}\n \\item $\\inv{(\\inv{a})} = a$\n \\item $a^m \\cdot a^n = a^{m+n}$, $(a^m)^n = a^{m \\cdot n}$\n \\item $\\inv{(a \\cdot b)} = \\inv{b} \\cdot \\inv{a}$\n \\end{nestedlemlist}\n\\end{lemlist}\n\\end{lem}\n\\begin{proof}[Proof of (b)(iii)] $(a \\cdot b) \\cdot \\inv{b} \\cdot \\inv{a} = a \\cdot \\underbrace{(b \\cdot \\inv{b})}_{=e} \\cdot \\inv{a} = a \\cdot \\inv{a} = e$.\n\\end{proof}\n\n\\begin{defn}[Subgroup]\\label{defn:subgroup}\nA subset $U \\subseteq G$ is called a \\emph{subgroup}\\index{subgroup} of a group $G$ (denoted $U \\subgroup G$) if $U$ itself is a group with mapping $\\cdot$. That is, $U$ is a subgroup iff \\begin{defnlist}\n \\item $e \\in U$; \\margintag{$U$ contains the neutral element}\n \\item $\\forall a, b \\in U.\\quad a \\cdot b \\in U$; and \\margintag{the mapping $\\cdot$ is closed wrt. $U$}\n \\item $\\forall a \\in U.\\quad \\inv{a} \\in U.$ \\margintag{the mapping $\\inv{(\\dots)}$ is closed wrt. $U$}\n\\end{defnlist} Associativity follows from $G$ being a group.\n\\end{defn}\n\n\\begin{ex}{Subgroups}{}\n\\begin{itemize}\n \\item $\\{e\\}, G \\subgroup G$ (\\emph{trivial subgroups}\\index{trivial subgroups})\n \\item $\\SL{n}{K} \\subgroup \\GL{n}{K}$\n \\item Let $2\\Z \\defeq \\{2m \\mid m \\in \\Z\\}$, then $(2\\Z,+) \\subgroup (\\Z,+)$\n\\end{itemize}\n\\end{ex}\n\n\\begin{rmk}\\label{rmk:cap_subgroup}\nIf $\\{U_i\\}_{i \\in I}$ are subgroups of $G$, then $\\bigcap_{i \\in I} U_i \\subgroup G$.\n\\end{rmk}\n\n\\begin{defn}[Generated Subgroup]\nFor any $M \\subseteq G$, \\begin{align}\n \\gen{M} \\defeq \\bigcap_{\\substack{U \\subgroup G \\\\ M \\subseteq U}} U \\subgroup G, \\margintag{by \\cref{rmk:cap_subgroup}}\n\\end{align} is the \\emph{subgroup generated by $M$}\\index{generated subgroup}. In particular, $\\gen{M}$ is the ``smallest'' subgroup that includes $M$.\n\\end{defn}\n\n\\begin{lem}\nFor $M \\neq \\emptyset$, we have \\begin{align}\n \\gen{M} = \\{a_1 \\cdot a_2 \\cdots a_n \\mid n \\in \\N, \\text{$a_i \\in M$ or $\\inv{a_i} \\in M$}\\}.\n\\end{align}\n\\end{lem} \\begin{proof}[Proof (sketch)]\\leavevmode\nLet $N \\defeq \\{a_1 \\cdot a_2 \\cdots a_n \\mid n \\in \\N, \\text{$a_i \\in M$ or $\\inv{a_i} \\in M$}\\}$.\n\\begin{itemize}\n \\item \\underline{$\\gen{M} \\subseteq N$}: $N \\subgroup G$ and $M \\subseteq N \\implies \\gen{M} \\subseteq N$ \\margintag{using that $\\gen{M}$ is the smallest subgroup including $M$}\n \\item \\underline{$N \\subseteq \\gen{M}$}: if $U \\subgroup G$ with $M \\subseteq U$, then $U$ includes all of these products $\\implies N \\subseteq U \\implies N \\subseteq \\gen{M}$ \\qedhere\n\\end{itemize}\n\\end{proof}\n\n\\begin{ex}{Generated subgroup}{}\n$S_3 = \\{\\id, \\underbrace{(1\\ 2)}_{\\tau_1}, \\underbrace{(1\\ 3)}_{\\tau_2}, \\underbrace{(2\\ 3)}_{\\tau_3}, \\underbrace{(1\\ 2\\ 3)}_{\\sigma_1}, \\underbrace{(1\\ 3\\ 2)}_{\\sigma_2}\\} = \\gen{\\{\\underbrace{(1\\ 2)}_{\\tau_1}, \\underbrace{(1\\ 2\\ 3)}_{\\sigma_1}\\}}$.\n\\end{ex}\n\n\\begin{defn}[Cyclic Group]\nA group $G$ is \\emph{cyclic}\\index{cyclic group} if $\\exists a \\in G$ with \\begin{align}\n G = \\gen{a} \\defeq \\gen{\\{a\\}} = \\{a^m \\mid m \\in \\Z\\}.\n\\end{align} Such an $a \\in G$, is called a \\emph{generator}\\index{generator} of $G$.\n\\end{defn}\n\n\\begin{marginfigure}\n \\includegraphics[width=\\textwidth]{c_cyclic_subgroup.png}\n \\caption{An illustration of the cyclic subgroup $\\gen{i}$ in the complex plane.}\n\\end{marginfigure}\n\n\\begin{ex}{Cyclic groups}{}\n\\begin{itemize}\n \\item $\\gen{i} = \\{i^m \\mid m \\in \\Z\\}$ is a cyclic subgroup of $(\\woZ{\\C},\\cdot)$, \\begin{align*}\n \\gen{i} &= \\{\\dots, \\underbrace{i^{-2}}_{=-1}, \\underbrace{i^{-1}}_{=-i}, 1, i, \\underbrace{i^2}_{=-1}, \\underbrace{i^3}_{=-i}, \\underbrace{i^4}_{=1}, \\underbrace{i^5}_{=i}, \\dots\\} \\\\\n &= \\{1, i, -1, -i\\}.\n \\end{align*}\n \\item $(\\Z,+) = \\gen{1} = \\{\\dots, -2, -1, 0, 1, 2, \\dots\\}$ is cyclic\n\\end{itemize}\n\\end{ex}\n\n\\begin{defn}[Order]\\index{order}\nLet $G$ be a group.\n\\begin{defnlist}\n \\item The cardinality $|G| \\in \\wInfty{\\N}$ is called \\emph{order} of the group $G$.\n \\item For any $a \\in G$, $o(a) \\defeq |\\gen{a}|$ is the \\emph{order} of the element $a$.\n\\end{defnlist} If $|G| < \\infty$, $G$ is called \\emph{finite}\\index{finite group}.\n\\end{defn}\n\n\\begin{lem}\nIf $k \\defeq o(a) < \\infty$, we have \\begin{lemlist}\n \\item $o(a) = \\min\\{j \\in \\N \\mid a^j = e\\}$;\n \\item $\\gen{a} = \\{e, a, a^2, \\dots, a^{k-1}\\}$; and\n \\item\\label{lem:order_identity} For any $j \\in \\Z$, $a^j = e \\iff \\divides{o(a)}{j}$.\\footnote{We use $\\divides{a}{b}$ to denote that $a$ divides $b$.}\n\\end{lemlist}\n\\end{lem} \\begin{proof}\nWe write $m \\defeq \\min\\{j \\in \\N \\mid a^j = e\\}$. \\begin{itemize}\n \\item \\underline{$\\{e, a, a^2, \\dots, a^{m-1}\\} \\subseteq \\gen{a}$}: Let us fix an arbitrary $j \\in \\N$. We have, \\begin{align*}\n o(a) = |\\gen{a}| < \\infty &\\implies \\exists j' > j.\\ a^j = a^{j'} \\margintag{as the order of $a$ is finite} \\\\\n &\\implies a^{j'-j} = e \\margintag{by multiplying from the right with $a^{-j}$} \\\\\n &\\implies \\text{$m$ exists and $\\{e, a, a^2, \\dots, a^{m-1}\\} \\subseteq \\gen{a}$}. \\margintag{as $j'-j \\in \\N$ is again a natural number}\n \\end{align*}\n \\item \\underline{$\\gen{a} \\subseteq \\{e, a, a^2, \\dots, a^{m-1}\\}$}: We fix any $n \\in \\Z$. Then, by \\emph{long division}\\index{long division}, there exist $q, r \\in \\Z$ and $0 \\leq r < m$ with $n = q \\cdot m + r$. This yields, \\begin{align*}\n a^n = a^{q \\cdot m + r} = \\underbrace{(a^m)^q}_{=e} \\cdot a^r = a^r \\in \\{e, a, a^2, \\dots, a^{m-1}\\}.\n \\end{align*}\n\\end{itemize} This proves that $m = o(a)$ and $\\gen{a} = \\{e, a, a^2, \\dots, a^{m-1}\\}$. It also follows that \\begin{align*}\n a^n = e \\iff r = 0 \\iff \\divides{m}{n}. &\\qedhere\n\\end{align*}\n\\end{proof}\n\n\\begin{rmk}\nFor a finite cyclic group $\\gen{a} = \\{e, a, a^2, \\dots, a^{k-1}\\}$ of order $k$, we have $a^{k-j} = a^{-j}$.\n\\end{rmk}\n\n\\begin{ex}{Order}{}\n\\begin{itemize}\n \\item Let us consider $\\GL{2}{\\R}$. Then, \\begin{align*}\n \\mA = \\begin{bmatrix}\n 2 & 0 \\\\\n 0 & 2 \\\\\n \\end{bmatrix} &\\implies \\forall n \\in N.\\ \\mA^n = \\begin{bmatrix}\n 2^n & 0 \\\\\n 0 & 2^n \\\\\n \\end{bmatrix} \\neq \\mI \\\\ &\\implies o(\\mA) = \\infty, \\\\\n \\mB = \\begin{bmatrix}\n 0 & 1 \\\\\n -1 & 0 \\\\\n \\end{bmatrix} &\\implies \\begin{multlined}[t]\\mB^2 = \\begin{bmatrix}\n -1 & 0 \\\\\n 0 & -1 \\\\\n \\end{bmatrix}, \\\\ \\mB^3 = -\\mB = \\begin{bmatrix}\n 0 & -1 \\\\\n 1 & 0 \\\\\n \\end{bmatrix}, \\mB^4 = (\\mB^2)^2 = \\mI\\end{multlined} \\\\ &\\implies o(\\mB) = 4.\n \\end{align*}\n \n \\item $|S_n| = |\\{\\sigma : [n] \\to [n] \\mid \\text{$\\sigma$ is bijective}\\}| = n!$\n\\end{itemize}\n\\end{ex}\n\n\\begin{ex}{Subgroups of $S_3$}{s3_subgroups}\nLet us find the subgroups of \\begin{align*}\n S_3 = \\{\\id, (1\\ 2), (1\\ 3), (2\\ 3), (1\\ 2\\ 3), (1\\ 3\\ 2)\\}.\n\\end{align*} We immediately obtain the trivial subgroups $\\{\\id\\}$ and $S_3$ or order $1$ and $6$, respectively. It is a simple exercise to confirm the following cyclic subgroups: \\begin{itemize}\n \\item $\\gen{(1\\ 2)} = \\{\\id, (1\\ 2)\\}$\n \\item $\\gen{(1\\ 3)} = \\{\\id, (1\\ 3)\\}$\n \\item $\\gen{(2\\ 3)} = \\{\\id, (2\\ 3)\\}$\n \\item $\\gen{(1\\ 2\\ 3)} = \\gen{(1\\ 3\\ 2)} = \\{\\id, (1\\ 2\\ 3), (1\\ 3\\ 2)\\}$\n\\end{itemize} The first three subgroups generated by 2-cycles are of order 2, the last subgroup generated by the 3-cycles is of order 3.\n\nObserve that the subgroup orders are divisors of the group order. This is not coincidental, we will make this precise in the following. In doing so, we will also find that our list of subgroups of $S_3$ was indeed exhaustive.\n\\end{ex}\n\n\\begin{marginfigure}\n \\includegraphics[width=\\textwidth]{s3_subgroup_graph.png}\n \\caption{Subgroup graph of the symmetric group $S_3$. The order of the subgroups is shown in orange.}\\label{fig:s3_subgroup_graph}\n\\end{marginfigure}\n \nThe subgroup structure of a group $G$ can be graphically represented in a \\emph{subgroup graph}\\index{subgroup graph}. Subgroups of $G$ are represented as vertices. Groups $U$ and $V$ are connected if $U \\subgroup V$ and there exists no subgroup ``between'' $U$ and $V$. An example is given in \\cref{fig:s3_subgroup_graph}.\n\n\\begin{defn}[Cosets and Index]\nLet $U \\subgroup G$ be a subgroup.\n\\begin{defnlist}\n \\item For $a \\in G$, \\begin{align}\n aU &\\defeq \\{a \\cdot u \\mid u \\in U\\}, \\label{eq:left_coset} \\\\\n Ua &\\defeq \\{u \\cdot a \\mid u \\in U\\},\n \\end{align} are the left\\index{left coset} and right\\index{right coset} \\emph{coset}\\index{coset} of $U$ in $G$, respectively.\n \\item\\label{defn:index} The \\emph{index}\\index{index} $[G : U] \\defeq |\\{aU \\mid a \\in G\\}|$ of $U$ in $G$ is defined as the number of cosets of $U$ in $G$.\\footnote{The number of left cosets is identical to the number of right cosets.}\n\\end{defnlist}\n\\end{defn}\n\n\\begin{lem}\nFor all $a, b \\in G$, we have\n\\begin{lemlist}\n \\item $aU = U \\iff a \\in U$\n \\item\\label{lem:cosets_eq} $aU = bU \\iff \\inv{a} b \\in U$\n \\item $aU \\cap bU \\neq \\emptyset \\iff aU = bU$\n \\item $G = \\bigcup_{a \\in G} aU$\n \\item\\label{lem:cosets_size} $|aU| = |U|$\n\\end{lemlist}\n\\end{lem} \\begin{proof}[Proof of (e)]\n$U \\to aU, u \\mapsto a \\cdot u$ is a bijective mapping. Hence, domain and codomain are of the same size.\n\\end{proof}\n\n\\begin{thm}[Lagrange's Theorem]\\index{Lagrange's theorem}\\label{thm:lagrange}\nIf $G$ is a finite group and $U \\subgroup G$ is some subgroup, then \\begin{align}\n |G| = |U| \\cdot [G : U].\n\\end{align} In particular, $|U|$ and $[G : U]$ are divisors of $|G|$.\n\\end{thm} \\begin{proof}\nLet $r \\defeq \\Index{G}{U}$. Then we can write $G$ as a disjoint union of cosets, \\begin{align*}\n G = a_1 U \\cupdot a_2 U \\cupdot \\cdots \\cupdot a_r U.\n\\end{align*} We have, \\begin{align*}\n |G| = \\sum_{i=1}^r |a_i U| = r \\cdot |U| = \\Index{G}{U} \\cdot |U|. \\margintag{using that $|a_i U| = |U|$ by \\cref{lem:cosets_size}} &\\qedhere\n\\end{align*}\n\\end{proof}\n\n\\begin{cor}\nLet $G$ be a finite group. Then we have for any $a \\in G$, \\begin{corlist}\n \\item $\\divides{o(a)}{|G|}$\n \\item $a^{|G|} = e$ \\quad (\\emph{Fermat's little theorem}\\index{Fermat's little theorem})\n\\end{corlist}\n\\end{cor} \\begin{proof}\n\\leavevmode\\begin{corlist}\n\\item By \\hyperref[thm:lagrange]{Lagrange's theorem}, $\\divides{|\\gen{a}|}{|G|}$.\n\\item By \\cref{lem:order_identity}, $a^{|G|} = e \\iff \\divides{o(a)}{|G|}$. \\qedhere\n\\end{corlist}\n\\end{proof}\n\n\\begin{cor}\\label{cor:prime_group_is_cyclic}\nLet $G$ be a group such that $|G| = p$ where $p$ is prime. Then, $G$ is cyclic.\n\\end{cor} \\begin{proof}\n\\begin{align*}\n |G| > 1 &\\implies \\exists a \\in G \\setminus \\{e\\} \\\\\n &\\implies \\divides{1 \\neq |\\gen{a}|}{|G|} \\margintag{using that $o(a) \\geq 2$ if $a \\neq e$ and \\hyperref[thm:lagrange]{Lagrange's theorem}} \\\\[5pt]\n &\\implies |\\gen{a}| = p = |G|. \\margintag{using that $|G|$ only has divisors $1$ and $p$}\n\\end{align*} Therefore, $\\gen{a} = G$.\n\\end{proof}\n\n\\begin{ex}{Subgroups of $S_3$ (continued)}{}\nWe will now see that $S_3$ has exactly four non-trivial subgroups, proving that we have found all subgroups of $S_3$ in \\cref{ex:s3_subgroups}.\n\nLet ${U \\subgroup S_3}$ be a non-trivial subgroup. By \\hyperref[thm:lagrange]{Lagrange's theorem}, we have ${\\divides{|U|}{|S_3| = 3! = 6}}$. As we have excluded the trivial subgroups $\\{\\id\\}$ and $S_3$, we know that ${|U| \\neq 1, 6}$. This leaves us with ${|U| \\in \\{2,3\\}}$.\n\nObserve that $2$ and $3$ are prime, hence, by \\cref{cor:prime_group_is_cyclic} $U$ must be cyclic. Recall that we have already enumerated all (four) cyclic subgroups of $S_3$ in \\cref{ex:s3_subgroups}.\n\\end{ex}\n\n\\section{Homomorphisms}\nWe will now consider two groups $(G,\\cdot)$ and $(H,\\cdot)$. To understand the relationship between $G$ and $H$, it is useful to look at mappings between the two groups. A special mapping that (as we will see) preserves the structure of a group, is the group homomorphism.\n\n\\begin{defn}[(Group) Homomorphism]\n\\leavevmode\\begin{defnlist}\n \\item The mapping $\\varphi : G \\to H$ is called a \\emph{(group) homomorphism}\\index{homomorphism}\\index{group homomorphism} if \\begin{align}\n \\forall a, b \\in G.\\quad \\varphi(a \\cdot b) = \\varphi(a) \\cdot \\varphi(b). \\label{eq:homomorphism}\n \\end{align} The homomorphism $\\psi : G \\to G$ is called \\emph{endomorphism}\\index{endomorphism} of $G$.\n \\item The set of elements that are mapped to the neutral element $e_H$, \\begin{align}\n \\ker{\\varphi} \\defeq \\{a \\in G \\mid \\varphi(a) = e_H\\} \\subseteq G, \\label{eq:kernel}\n \\end{align} is called the \\emph{kernel}\\index{kernel} of $\\varphi$.\n \\item The set of elements in the codomain $H$ that $\\varphi$ maps to, \\begin{align}\n \\im{\\varphi} \\defeq \\{\\varphi(a) \\mid a \\in G\\} \\subseteq H,\n \\end{align} is called the \\emph{image}\\index{image} of $\\varphi$.\n\\end{defnlist}\n\\end{defn}\n\n\\begin{ex}{Homomorphisms}{homomorphisms}\n\\begin{itemize}\n \\item ${\\varphi : G \\to H, a \\mapsto e_H}$ is the \\emph{trivial homomorphism}\\index{trivial homomorphism}\n \n \\item For any field $K$, ${\\det : \\GL{n}{K} \\to \\woZ{K}, \\mA \\mapsto \\det{\\mA}}$ is a homomorphism due to the multiplicativity of the determinant.\\marginfootnote{Recall that $\\det{(\\mA \\cdot \\mB)} = \\det{\\mA} \\cdot \\det{\\mB}$.} We have for its kernel, \\begin{align}\n \\ker{\\det} = \\{\\mA \\in \\GL{n}{K} \\mid \\det{\\mA} = 1\\} = \\SL{n}{K}. \\label{eq:det_kernel}\n \\end{align}\n \n \\item Let us consider the \\emph{sign}\\index{sign} of a permutation, \\begin{align}\n \\sgn : S_n \\to \\{-1, 1\\}, \\sigma \\mapsto (-1)^{N(\\sigma)},\n \\end{align} where $N(\\sigma)$ is the number of inversions in $\\sigma$. An \\emph{inversion}\\index{inversion} in $\\sigma$ is a pair of elements that is out of order. More formally, \\begin{align}\n N(\\sigma) = |\\{(i,j) \\mid \\text{$i < j$ and $\\sigma(i) > \\sigma(j)$}\\}|.\n \\end{align} For an $r$-cycle the sign reduces to, \\begin{align}\n \\sgn{\\underbrace{(i_1\\ \\cdots\\ i_r)}_{\\text{$r$-cycle}}} = (-1)^{r-1}.\n \\end{align}\n \n It can be shown that $\\sgn$ is a homomorphism, that is, \\begin{align}\n \\forall \\sigma, \\tau \\in S_n.\\quad \\sgn{(\\sigma \\circ \\tau)} = \\sgn{\\sigma} \\cdot \\sgn{\\tau}.\n \\end{align} The kernel of $\\sgn$ is the set of permutations with positive sign, \\begin{align}\n \\ker{\\sgn} = \\{\\sigma \\in S_n \\mid \\sgn{\\sigma} = 1\\} \\eqdef A_n. \\label{eq:alternating_group}\n \\end{align} This set forms again a group, which is known as the \\emph{alternating group}\\index{alternating group} $A_n$.\n \n \\item Within the group $(\\Z,+)$, $\\varphi : \\Z \\to \\Z, m \\mapsto 2 m$ is an endomorphism.\n\\end{itemize}\n\\end{ex}\n\n\\begin{lem}[Properties of Homomorphisms]\nLet $\\varphi : G \\to H$ be a homomorphism. Then,\n\\begin{lemlist}\n \\item $\\varphi(e_G) = e_H$\n \\item $\\forall g \\in G.\\ \\varphi(\\inv{g}) = \\inv{\\varphi(g)}$\n \\item\\label{lem:homomorphism_kernel_subgroup} $\\ker{\\varphi} \\subgroup G$ and $\\im{\\varphi} \\subgroup H$\n \\item $\\text{$\\varphi$ injective} \\iff \\ker{\\varphi} = \\{e_G\\}$\n \\item if $\\psi : H \\to K$ is a homomorphism, then $\\psi \\circ \\varphi : G \\to K$ is a homomorphism\n\\end{lemlist}\n\\end{lem} \\begin{marginfigure}\n \\includegraphics[width=\\textwidth]{injective_surjective.png}\n \\caption{An illustration of \\emph{injectivity}\\index{injective} and \\emph{surjectivity}\\index{surjective}. When a function $\\varphi$ is injective, $\\varphi(a) = \\varphi(b)$ implies $a = b$. We call a function \\emph{bijective}\\index{bijective} is it is both injective and surjective, i.e., a one-to-one mapping.}\n\\end{marginfigure} \\begin{proof}\n\\leavevmode\\begin{lemlist}\n \\item We have $\\varphi(e_G) = \\varphi(e_G \\cdot e_G) = \\varphi(e_G) \\cdot \\varphi(e_G)$, using the compatibility of a homomorphism with the group structure \\eqref{eq:homomorphism}. By multiplying with $\\inv{\\varphi(e_G)}$ from one side, we obtain that this statement is true if and only if $\\varphi(e_G) = e_H$.\n \n \\item Again, using the homomorphism property, we have, \\begin{align*}\n e_H = \\varphi(e_G) = \\varphi(g \\cdot \\inv{g}) = \\varphi(g) \\cdot \\varphi(\\inv{g}).\n \\end{align*} By multiplying from the left with $\\inv{\\varphi(g)}$, we obtain that this statement is true if and only if $\\inv{\\varphi(g)} = \\varphi(\\inv{g})$.\n \n \\item Let us confirm the properties of subgroups for $\\ker{\\varphi} \\subgroup G$. The proof is analogous for $\\im{\\varphi} \\subgroup H$. By \\cref{defn:subgroup}, we need to show, \\begin{nestedlemlist}\n \\item $e_G \\in \\ker{\\varphi}$ follows immediately from (a)\n \\item $\\forall a, b \\in \\ker{\\varphi}.\\ \\varphi(a \\cdot b) = \\varphi(a) \\cdot \\varphi(b) = e_H \\cdot e_H = e_H$. Therefore, $\\ker{\\varphi}$ is closed under the group operation, $a \\cdot b \\in \\ker{\\varphi}$.\n \\item $\\forall a \\in \\ker{\\varphi}.\\ \\varphi(\\inv{a}) = \\inv{\\varphi(a)} = \\inv{e_H} = e_H$. Therefore, $\\ker{\\varphi}$ is closed under inversion, $\\inv{a} \\in \\ker{\\varphi}$.\n \\end{nestedlemlist}\n $\\implies \\ker{\\varphi} \\subgroup G$.\n \n \\item \\begin{itemize}\n \\item \\underline{``$\\Rightarrow$''}: Let $\\varphi$ be injective. We want to show that $\\ker{\\varphi} = \\{e_G\\}$. Note that (a) already implies $\\{e_G\\} \\subseteq \\ker{\\varphi}$. To show $\\ker{\\varphi} \\subseteq \\{e_G\\}$, let $a \\in \\ker{\\varphi}$. Then, \\begin{align*}\n \\varphi(a) = e_H \\overset{(a)}{=} \\varphi(e_H).\n \\end{align*} As $\\varphi$ is injective, it follows that $a = e_H$.\n \\item \\underline{``$\\Leftarrow$''}: Let $\\ker{\\varphi} = \\{e_G\\}$. We want to show that $\\varphi$ is injective. Let $a, b \\in G$ with $\\varphi(a) = \\varphi(b)$. By multiplying from the right with $\\inv{\\varphi(b)}$, we obtain, \\begin{align*}\n e_H = \\varphi(a) \\cdot \\inv{\\varphi(b)} = \\varphi(a) \\cdot \\varphi(\\inv{b}) = \\varphi(a \\cdot \\inv{b}).\n \\end{align*} As the kernel of $\\varphi$ only contains $e_G$, we follow, \\begin{align*}\n e_G = a \\cdot \\inv{b} \\overset{\\cdot b}{\\implies} a = b \\implies \\text{$\\varphi$ injective}.\n \\end{align*}\n \\end{itemize}\n \n \\item Let $a, b \\in G$. Then, \\begin{align*}\n (\\psi \\circ \\varphi)(a \\cdot b) &= \\psi(\\varphi(a \\cdot b)) = \\psi(\\varphi(a) \\cdot \\varphi(b)) \\margintag{using that $\\varphi$ is a homomorphism} \\\\\n &= \\psi(\\varphi(a)) \\cdot \\psi(\\varphi(b)) = (\\psi \\circ \\varphi)(a) \\cdot (\\psi \\circ \\varphi)(b). \\margintag{using that $\\psi$ is a homomorphism} \\qedhere\n \\end{align*}\n\\end{lemlist}\n\\end{proof}\n\n\\begin{defn}[Isomorphism]\n\\leavevmode\\begin{defnlist}\n \\item The mapping $\\varphi : G \\to H$ is called an \\emph{isomorphism}\\index{isomorphism} if $\\varphi$ is a homomorphism and bijective. The isomorphism $\\psi : G \\to G$ is called an \\emph{automorphism}\\index{automorphism} of $G$.\n \\item $G$ and $H$ are called \\emph{isomorphic} (denoted $G \\isom H$) if there exists an isomorphism $\\varphi : G \\to H$.\n \\item $\\Aut{G} \\defeq \\{\\psi : G \\to G \\mid \\text{$\\psi$ automorphism}\\}$ forms a group under function composition ``$\\circ$''. This group is called the \\emph{automorphic group}\\index{automorphic group} of $G$.\n\\end{defnlist}\n\\end{defn}\n\n\\begin{rmk}\nIf $\\varphi : G \\to H$ is an isomorphism, then $\\inv{\\varphi} : H \\to G$ is an isomorphism.\n\\end{rmk}\n\n\\begin{ex}{Isomorphisms}{}\n\\begin{itemize}\n \\item Given a group $G$ and an arbitrary element $g \\in G$, \\begin{align}\n i_g : G \\to G, x \\mapsto g \\cdot x \\cdot \\inv{g},\n \\end{align} is the \\emph{inner automorphism}\\index{inner automorphism} of the so-called \\emph{conjugating element}\\index{conjugating element} $g$. This isomorphism corresponds to the conjugation group action (also called \\emph{(left) conjugation}\\index{conjugation} by $g$), which we will encounter again in \\cref{sec:groups:actions}.\n \n \\item $\\exp : (\\R,+) \\to (\\RgZ,\\cdot), x \\mapsto e^x$ is an isomorphism.\\marginfootnote{$\\exp$ is a homomorphism due to $e^{x+y} = e^x e^y$. As $\\exp$ is strictly monotonically increasing, it is bijective.}\n\\end{itemize}\n\\end{ex}", "meta": {"hexsha": "6819c359149b24df8d0069fdf318e541cf2a103a", "size": 26480, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/01_groups_and_homomorphisms.tex", "max_stars_repo_name": "jonhue/algebra", "max_stars_repo_head_hexsha": "b91da0f3fff239010d0584535f1b5f0d4f0184aa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapters/01_groups_and_homomorphisms.tex", "max_issues_repo_name": "jonhue/algebra", "max_issues_repo_head_hexsha": "b91da0f3fff239010d0584535f1b5f0d4f0184aa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapters/01_groups_and_homomorphisms.tex", "max_forks_repo_name": "jonhue/algebra", "max_forks_repo_head_hexsha": "b91da0f3fff239010d0584535f1b5f0d4f0184aa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 59.7742663657, "max_line_length": 578, "alphanum_fraction": 0.6274924471, "num_tokens": 9693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218305645894, "lm_q2_score": 0.912436157500568, "lm_q1q2_score": 0.8411948125962436}} {"text": "\n\\subsection{Cumulative distribution functions}\n\n\\subsubsection{Definition}\n\nRandom variables all valued as real numbers, and so we can write:\n\n\\(P(X\\le x)=P({\\omega |X(\\omega)\\le x})\\)\n\nOr:\n\n\\(F_X(x)=\\int_{-\\infty}^x f_X(u)du\\)\n\n\\(F_X(x)=\\sum_{x_i\\le x}P(X=x_i) \\)\n\n\\subsubsection{Partitions}\n\n\\(P(X\\le x)+P(X\\ge x)-P(X=x)=1\\)\n\n\\subsubsection{Interval}\n\n\\(P(a< X\\le b)=F_X(b)-F_X(a)\\)\n\n", "meta": {"hexsha": "afe39b514f1df7663b0255aaf0f2eb176ff8cc00", "size": 387, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/probability/probabilityVariables/01-03-cumulative.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/probability/probabilityVariables/01-03-cumulative.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/probability/probabilityVariables/01-03-cumulative.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.125, "max_line_length": 65, "alphanum_fraction": 0.6434108527, "num_tokens": 145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377237352755, "lm_q2_score": 0.8774767762675405, "lm_q1q2_score": 0.8410945917540559}} {"text": "\n\\subsection{Defining linear models}\n\n\\subsubsection{Defining}\n\nOne option for \\(f(X)\\) is a linear model.\n\n\\(f(X_i)=\\hat{Y_i}= \\beta_0+\\sum_{j=1}^p\\beta_iX_{ij}\\)\n\nThe values for \\(\\beta \\) are the regression coefficients.\n\nSo we have:\n\n\\(Y_i=\\beta_0+\\sum_{j=1}^p\\beta_iX_{ij}+e(X_i)+e_i\\)\n\nWe define the error of the estimate as:\n\n\\(\\epsilon_i=Y_i-\\hat{Y_i}\\)\n\n\\(\\epsilon_i=e(X_i)+e_i \\)\n\nSo:\n\n\\(Y_i=\\beta_0+\\sum_{j=1}^p\\beta_iX_{ij}+\\epsilon_i\\)\n\nThe linear model could be wrong for two reasons. No linear model could be appropriate, or the wrong coefficients could be provided for a linear model.\n\nLinear regression if \\(f\\) is a linear function on \\(w\\). NB: not linear in \\(x\\) necessarily. could have \\(x^2\\) etc, but still linear in \\(w\\).\n\n", "meta": {"hexsha": "b8521e1a91852753ede2219111b3722f54f6014f", "size": 749, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/statistics/ols/01-01-linearModels.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/statistics/ols/01-01-linearModels.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/statistics/ols/01-01-linearModels.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9666666667, "max_line_length": 150, "alphanum_fraction": 0.6889185581, "num_tokens": 245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9658995772325382, "lm_q2_score": 0.870597273444551, "lm_q1q2_score": 0.8409095383598922}} {"text": "\\section{Limit Properties}\r\nLimit have many nice properties all allow us to make useful simplifications when evaluating a limit.\r\nLet\r\n\\begin{equation*}\r\n\t\\lim_{x \\to c}{f(x)} = L \\text{ and } \\lim_{x \\to c}{g(x)} = M.\r\n\\end{equation*}\r\n\\begin{align*}\r\n\t\\textbf{Sum and Difference Rule: }& \\lim_{x\\to c}{\\left(f(x) \\pm g(x)\\right)} = L \\pm M \\\\\r\n\t\\textbf{Product Rule: }& \\lim_{x\\to c}{\\left(f(x)g(x) \\right)} = LM \\\\\r\n\t\\textbf{Constant Multiple Rule: }& \\lim_{x \\to c}{k\\cdot f(x)} = k \\lim_{x \\to c}{f(x)} = kL \\\\\r\n\t\\textbf{Quotient Rule: }& \\lim_{x \\to c}{\\frac{f(x)}{g(x)}} = \\frac{\\lim_{x \\to x}{f(x)}}{\\lim_{x \\to c}{g(x)}} = \\frac{L}{M} \\text{, if} M \\neq 0 \\\\\r\n\t\\textbf{Power Rule: }& \\text{If } n \\neq \\in \\R \\text{, } \\lim_{x\\to c}{\\left(f(x)\\right)^n} = \\left(\\lim_{x \\to c}{f(x)}\\right)^n = L^n\r\n\\end{align*}\r\n\r\n\\subsection{``Substitution Rule''}\r\nAlthough it may seem obvious from our idea that limits describe behavior at a point that if $f(x)$ is defined at $x=c$, then $\\lim_{x\\to c}{f(x)} = f(c)$.\r\nHowever, this is \\textit{not} always the case.\r\nRemember that our definition of a limit required these $\\epsilon$ and $\\delta$ neighborhoods around the limit point.\r\nIf $f(x)$ is defined at $x=c$, but $(c, f(c))$ is not a point in these neighborhoods for any $\\epsilon > 0$, then the limit will not evaluate to $f(c)$.\r\n\r\n\\begin{example}\r\n\tFind the limit of $f(x)$ as $x$ approaches $2$ for the following function.\r\n\t\\begin{equation*}\r\n\t\tf(x) = \\begin{cases}\r\n\t\t\tx^2 & x \\neq 2 \\\\\r\n\t\t\t0 & x = 2\r\n\t\t\\end{cases}.\r\n\t\\end{equation*}\r\n\\end{example}\r\n\\begin{answer}\r\n\tWe can clearly see that $f(2) = 0$, but for $\\epsilon = 0.1$, for example, there is no $\\delta$ that can satisfy our definition, as points like $(2 - \\delta, 4 - 2\\delta + \\delta^2)$ would outside the neighborhood around $(2,0)$.\r\n\tIn fact, the correct limit value is $4$, the same as if $f(x) = x^2$ for all $x$.\r\n\tThere are some more nuances we'll need to describe before we can say when it's OK to substitute to evaluate a limit.\r\n\\end{answer}", "meta": {"hexsha": "20bc6debecae62f7cbd65bdfa4b70f78dce6ff97", "size": 2026, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "calc/limits_continuity/limit_properties.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "calc/limits_continuity/limit_properties.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "calc/limits_continuity/limit_properties.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 59.5882352941, "max_line_length": 232, "alphanum_fraction": 0.6322803554, "num_tokens": 711, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240177362486, "lm_q2_score": 0.8962513655129178, "lm_q1q2_score": 0.8407949319165776}} {"text": "\\section{Integer Linear Programming Model}\n\tIn this section will be presented the model implemented using Cplex as solver.\n\t\\subsection{Network Flow Model Representation}\n\t\tThe problem can be represented on a complete weighted graph $G=(N, A)$ where $N$ is the set of nodes (holes on the board) and $A$ is the set of the arcs $(i, j), ∀ i, j ∈ N$ (trajectory of the drill moving from hole $i$ to hole $j$).To each arc will be associated a weight $c_{ij}$ that represents the time needed to move from starting hole to destination.\n\t\t\n\t\tUsing this representation the problem is equivalent to determine the minimum weight hamiltonian cycle on G, so it is like the very popular Travelling Salesman Problem (TSP).\n\t\t\n\t\tTo solve the TSP problem we can formulate it as a network flow model on G. Given a starting node $0 ∈ N$, let $|N|$ be the amount of its output flow, the problem can be solved by finding the path for which:\n\t\t\\begin{itemize}\n\t\t\t\\item Each node receives 1 unit of flow\n\t\t\t\\item Each node is visited once\n\t\t\t\\item The sum of costs in selected arcs is minimum\n\t\t\\end{itemize}\n\t\t\n\t\\subsection{Variables and Constraints}\n\t\tThe problem can then be represented like this:\\\\\n\t\t\\newline\n\t\t\\textbf{SETS:}\\\\\n\t\t\\begin{addmargin}[2em]{0em}\n\t\t\t$N$ = the graph nodes (holes)\\\\\n\t\t\t$A$ = arcs in the form $(i, j), ∀ i, j ∈ N$ (trajectories between holes)\\\\\n\t\t\\end{addmargin}\n\t\t\\textbf{PARAMETERS:}\\\\\n\t\t\\begin{addmargin}[2em]{0em}\n\t\t\t$c_{ij}$ = time taken by the drill to move from $i$ to $j$, $∀ (i, j) ∈ A$\\\\\n\t\t\t$0$ = starting hole, $0 ∈ N$\\\\\n\t\t\\end{addmargin}\n\t\t\\textbf{DECISION VARIABLES:}\\\\\n\t\t\\begin{addmargin}[2em]{0em}\n\t\t\t$x_{ij}$ = amount of the flow shipped from $i$ to $j$, $∀ (i, j) ∈ A$\\\\\n\t\t\t$y_{ij}$ = 1 if arc $(i, j)$ ships some flow, 0 otherwise, $∀ (i, j) ∈ A$\\\\\n\t\t\\end{addmargin}\n\t\t\\textbf{OBJECTIVE FUNCTION:}\\\\\n\t\t\\[min \\sum_{i, j | (i, j) ∈ A} c_{ij} \\cdot y_{ij}\\]\\\\\n\t\t\\textbf{CONSTRAINTS:}\n\t\t\\begin{align*}\n\t\t\t&\\sum_{j | (0,j) ∈ A} x_{0j} = |N|\\\\\n\t\t\t\\\\\n\t\t\t&\\sum_{i | (i, k) ∈ A} x_{ik} - \\sum_{j | (k, j) ∈ A} x_{kj} = 1 & ∀ k ∈ N \\setminus \\{0\\}\\\\\n\t\t\t\\\\\n\t\t\t&\\sum_{j | (i, j) ∈ A} y_{ij} = 1 & ∀ i ∈ N\\\\\n\t\t\t\\\\\n\t\t\t&\\sum_{i | (i, j) ∈ A} y_{ij} = 1 & ∀ j ∈ N\\\\\n\t\t\t\\\\\n\t\t\t&x_{ij} \\leq |N| \\cdot y_{ij} & ∀ (i, j) ∈ A\\\\\n\t\t\t\\\\\n\t\t\t&x_{ij} ∈ \\mathbb{Z}_{+} & ∀ (i, j) ∈ A\\\\\n\t\t\t\\\\\n\t\t\t&y_{ij} ∈ \\{0, 1\\} & ∀ (i, j) ∈ A\n\t\t\\end{align*}\n\n\t\t\n\t\t", "meta": {"hexsha": "5a8595b509289c836497c4f5b8270c8a5f20a7fe", "size": 2348, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "report/sections/ilp_model.tex", "max_stars_repo_name": "abeccaro/MeMOC-project", "max_stars_repo_head_hexsha": "74d6b79ac72ed573c280478820a221424fc138f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-02-07T13:28:49.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-07T13:28:49.000Z", "max_issues_repo_path": "report/sections/ilp_model.tex", "max_issues_repo_name": "abeccaro/MeMOC-project", "max_issues_repo_head_hexsha": "74d6b79ac72ed573c280478820a221424fc138f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "report/sections/ilp_model.tex", "max_forks_repo_name": "abeccaro/MeMOC-project", "max_forks_repo_head_hexsha": "74d6b79ac72ed573c280478820a221424fc138f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.3018867925, "max_line_length": 358, "alphanum_fraction": 0.6086030664, "num_tokens": 886, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9637799420543366, "lm_q2_score": 0.8723473879530491, "lm_q1q2_score": 0.8407509150126415}} {"text": "\\begin{questions}\n\\question{Consider the predictor-corrector time-stepping scheme:\n\\begin{align*}\n& y_{n+1}^p = y_n + \\frac{\\Delta t}{12}(23f_n - 16f_{n-1}+5f_{n-2}), \\\\\n&y_{n+1} = y_n + \\frac{\\Delta t}{12}(5f(t_{n+1},y_{n+1}^p) + 8f)n - f_{n-1})~.\n\\end{align*}\nHere $f_n = f(t_n,y_n)$ and $y'(t) = f(t,y)$, $y(0) = y_0$. Plot the stability region for this scheme.\n }\n\n\\begin{solution}\n\nLet $y_{n+1}^p = P$ for simplicity. Then, for stability purposes, $f = \\lambda y$. Finally, let $a = \\frac{\\Delta t \\lambda}{12}$. Then,\n\\begin{align*}\n\\begin{cases}\nP = y^n + a(23y^n - 16y^{n-1}+5y^{n-1} \\\\\ny^{n+1} = y^n + a(5P + 8y^n - y^{n-1})\n\\end{cases} \\Rightarrow y^{n+1} = y^n + a \\left[ 5(y^n + a(23y^n- 16y^{n-1}+5y^{n-1})) + 8y^n - y^{n-1} \\right]~.\n\\end{align*} \n\nNow assume $y^{n+1} = gy^n$, and thus $y^n = g^2y^{n-2}$. Plugging this in, we get\n\\begin{align*}\ngy^n = y^n +a\\left[ 5y^n + 115ay^n - 80\\frac{a}{g}y^n + 25\\frac{a}{g^2}y^n\\right] + 8ay^n - \\frac{a}{g}y^n~.\n\\end{align*}\nSolving for $a$, we get\n\\begin{align*}\n&(115g^2 - 80g +25)a^2 + (13g^2-g)a + (g^2-g^3) = 0 \\\\\n& \\Rightarrow a = \\frac{-(13g^2 - g) \\pm \\sqrt{(13g^2-g)^2 - 4(115g^2 - 80g+25)(g^2-g^3)}}{2(115g^2 - 80g +25)}~.\n\\end{align*}\nLastly we let $z = 12a$ and plot the solution into Matlab to get the following stability region:\n\n\\begin{figure}[H]\n\\center{\\includegraphics[scale=.5]{P3F1.eps}}\n\\end{figure}\n\n\n\\end{solution}\n\n\\subsection*{MATLAB}\n\n\\begin{verbatim}\nclose all; clear variables;\n\ntheta = linspace(0,2*pi,100);\ng = exp(1i*theta);\na = 115*g.^2 - 80*g+25;\nb = 13*g.^2 - g;\nc = g.^2-g.^3;\nsq = sqrt(b.^2 - 4*a.*c);\n\nzp = 12*((-b + sq)./(2*a));\nzn = 12*((-b - sq)./(2*a));\n\nfigure\nplot(real(zp),imag(zp),'.r',real(zn),imag(zn),'.b')\nlegend('positive square root','negative square root')\ngrid on\n\\end{verbatim}\n\n\n\\end{questions}", "meta": {"hexsha": "2174f35eb2811ee302af6ff07b92328a39592549", "size": 1807, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Year_1/ComputationalMethods/Homework 5/Latex/tex_files/problem3camille.tex", "max_stars_repo_name": "fjcasti1/Courses", "max_stars_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Year_1/ComputationalMethods/Homework 5/Latex/tex_files/problem3camille.tex", "max_issues_repo_name": "fjcasti1/Courses", "max_issues_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Year_1/ComputationalMethods/Homework 5/Latex/tex_files/problem3camille.tex", "max_forks_repo_name": "fjcasti1/Courses", "max_forks_repo_head_hexsha": "12ab3e86a4a44270877e09715eeab713da45519d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1166666667, "max_line_length": 136, "alphanum_fraction": 0.5843940232, "num_tokens": 807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741281688026, "lm_q2_score": 0.8824278695464501, "lm_q1q2_score": 0.8405779585050637}} {"text": "\\subsection{Eigenvalue for rotation transformation}\n\n\\textbf{\\textit{Claim:}} \nIf $0< \\theta <2\\pi$ then transformation $R_\\theta : \\R^2\\rightarrow \\R^2$ only has an eigenvector when $\\theta=\\pi$ (when $\\lambda=-1$).\n\\newline \\noindent\n\\textbf{\\textit{Proof:}}\n\\noindent\nThe matrix is $A=\\begin{bmatrix}\\cos\\theta & -\\sin\\theta\\\\\\sin\\theta & \\cos\\theta\\end{bmatrix}$. Following by the definition of an eigenvector:\n\n\\[\n \\begin{aligned}\n A \\tb{v} &=\\lambda v \\Longleftrightarrow \\\\\n A \\tb{v}-\\lambda \\tb{v} &=\\overrightarrow{0} \\Longleftrightarrow \\\\\n A \\tb{v}-\\lambda(I \\tb{v}) &=\\overrightarrow{0} \\Longleftrightarrow \\\\\n A \\bar{v}-(\\lambda I) \\tb{v} &=\\overrightarrow{0} \\Longleftrightarrow \\\\\n (A-\\lambda I) \\tb{v} &=\\overrightarrow{0} \\Longleftrightarrow \\\\\n \\operatorname{det}(A-\\lambda I)&=0\n \\end{aligned} \n\\]\n\nThus,\n\n\\[\n \\begin{aligned}\n \\operatorname{det}(A-\\lambda I) &=0 \\\\\n \\operatorname{det}\\left(\\begin{array}{cc}\n \\cos \\theta-\\lambda & -\\sin \\theta \\\\\n \\sin \\theta & \\cos \\theta-\\lambda\n \\end{array}\\right) &=0 \\\\\n \\lambda^{2}-2 \\lambda \\cos \\theta+\\cos ^{2} \\theta+\\sin ^{2} \\theta &=0 \\\\\n \\lambda^{2}-2 \\lambda \\cos \\theta+1 &=0\n \\end{aligned} \n\\]\n\nThe discriminant of this quadratic ($b^2-4ac$) is $4\\cos^2\\theta-4$, so for a real solution $4\\cos^2\\theta-4\\geq 0$. It then follows\nthat:\n\n\\begin{align*}\n 4\\cos^2\\theta-4&\\geq 0\\\\\n \\cos^2\\theta&\\geq 1\\\\\n \\cos^2\\theta&=\\pm 1\\\\\n \\theta&=\\pi\n\\end{align*}\n\nNote that because $(A-\\lambda I)\\tb{v}=\\tb{0}$ implies a nontrivial kernel for $A-\\lambda I$, $\\mathrm{det}(A-\\lambda I)=0$.\n\n\\subsection{Characteristic Polynomials}\n\nCharacteristic polynomial is for $\\mathrm{det}(A-\\lambda I)$ with variable $\\lambda$: \n\n\\[\\boxed{P_A(\\lambda)=\\mathrm{det}(A-\\lambda I)}\\]\n\nGeneral polynomial for $A=\\begin{bmatrix}a&b\\\\c&d\\end{bmatrix}$:\n\n\\[\n \\begin{aligned}\n p_{A}(\\lambda) &=\\operatorname{det}(A-\\lambda I) \\\\\n &=\\operatorname{det}\\left(\\begin{array}{cc}\n a-\\lambda & b \\\\\n c & d-\\lambda\n \\end{array}\\right) \\\\\n &=(a-\\lambda)(d-\\lambda)-b c \\\\\n &=\\lambda^{2}-(a+b) \\lambda+(a d-b c) \n \\end{aligned}\n\\]\n\nEnds up that $\\mathrm{tr}(A)=a+d$ and $\\mathrm{det}(A)=ad-bc$:\n\n\\[\\boxed{p_{A}(\\lambda)=\\lambda^{2}-\\operatorname{tr} A \\lambda+\\operatorname{det} A}\\]\n\n\\subsubsection{General formula}\n\nIn general, if $A$ is an $n\\times n$ matrix, then\n\n\\[\\boxed{p_{A}(\\lambda)=(-1)^{n} \\lambda^{n}+(-1)^{n-1} \\operatorname{tr} A \\lambda^{n-1}+\\cdots+\\operatorname{det} A}\\]\n\nConjectures:\n\\begin{itemize}\n \\item By FTLA, degree $n$ polynomial will have $n$ complex roots so at least $n$ real eigenvalues\n \\item If all $n$ roots are real, then $\\mathrm{tr}(A)$ is sum of eigenvalues and determinant is the product of them\n \\item Since roots are either real or in complex conjugate pairs, ($a+bi$ or $a-bi$) then when $n$ is odd $A$ has at least 1 real eigenvalue\n\\end{itemize}", "meta": {"hexsha": "6757e4b72756d63c0872dc501cb8425357e9fd85", "size": 3017, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "linear-algebra/tex/18_matrix-eigenvalues.tex", "max_stars_repo_name": "sidnb13/latex-notes", "max_stars_repo_head_hexsha": "bbd935b7ff9781169775c052625b1917a47d5dcc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "linear-algebra/tex/18_matrix-eigenvalues.tex", "max_issues_repo_name": "sidnb13/latex-notes", "max_issues_repo_head_hexsha": "bbd935b7ff9781169775c052625b1917a47d5dcc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "linear-algebra/tex/18_matrix-eigenvalues.tex", "max_forks_repo_name": "sidnb13/latex-notes", "max_forks_repo_head_hexsha": "bbd935b7ff9781169775c052625b1917a47d5dcc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7926829268, "max_line_length": 143, "alphanum_fraction": 0.6135233676, "num_tokens": 1038, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897525789548, "lm_q2_score": 0.8933094003735664, "lm_q1q2_score": 0.840416329753902}} {"text": "\\chapter{Minimum Spanning Tree}\n\nGiven an undirected, connected graph where each edge has positive\nweight, the \\emph{Minimum Spanning Tree} (MST) is a connected subgraph on the same \nvertex set with minimal weight. Intuitively, the MST is the lightest possible\nconnected subgraph. The MST is not necessarily unique, \nfor proof of this, consider a graph where all edges are of equal weight. \nAny tree is an MST of such a graph. \n\n\\section{Kruskal's Algorithm}\n\n%The idea of this algorithm is to begin with the vertex list and an\n%empty edge list, and maintain a forest, adding the edge of minimum\n%weight that does not make a cycle until the forests are connected.\n\nKruskal's algorithm for computing the MST relies on the simple observation\nthat the smallest edge in a graph $G$ is part of \\emph{some} MST of $G$.\nKruskal's algorithm starts by constructing a min-heap containing all $m$ edges\nin $G$, and a collection of disjoint sets, each containing one of the\n$n$ vertices of $G$. We also construct an empty list $T$ that will hold\nall the edges of the MST. We then get the minimum edge from the heap, check if\nthe two nodes the edge joins are from the same set, and if not add \nthe edge to $T$, and $union$ the two sets that the edge joins.\nWe repeat this until $T$ contains $n-1$ edges. \n\nBecause this algorithm uses\nstructures we already know and understand, analysis will be fairly easy.\nWe require $O(m) + O(n)$ time to construct the initial sets and heap. We also\nrequire $O(m \\log m)$ to extract the minimums from the heap. Our $n-1$ unions\nand $n-1$ finds can be done in $(n \\log n + n)$ time. Therefore this algorithm\ntakes $O(m \\log m + n \\log n)$.\n\n\\section{Prim's Algorithm}\nPrim's algorithm for computing the MST is fairly similar to Kruskal's. However,\ninstead of working with all of the edges and vertices at once, it picks one\nvertice and builds from that. We start by constructing an empty list $A$ which\nwill hold all the vertices that are part of the MST so far, a list $T$ which\nwill hold all the edges in the MST so far, a min-heap $V$ which will contain all\nthe vertices not in $A$. At first every node is given a key of infinity. \nWe then pick a random vertex $v$ from $V$ and move it from $V$ \nto $A$. Next we look at all the edges of $v$ and set the\nkeys of the corresponding nodes to the weight of these edges. Now we retrieve\nthe minimum node $u$ from $V$ and move it to $A$, and its key edge to $T$. \nNext we look at all the edges on $u$ and if their weight is smaller than\nthe current key of their corresponding edge, set the key to that weight. Then\nwe simply retrieve another node from the heap and repeat. After $n-1$ iterations\nwe will have a complete MST.\n\nThis algorithm requires $O(n)$ time to construct the initial heap and \ninitialize the first node, and since we must update at most $m$ keys in the\nheap of $n$ elements, it requires $O(m \\log n)$ time to do this. Therefore the\nentire algorithm takes $O(n + m \\log n)$ time.\n\n", "meta": {"hexsha": "432dc0e0686ccf0bdd6ee7b70ffa8333d649f9f7", "size": 2967, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "mst.tex", "max_stars_repo_name": "SteamedPears/AllTheAlgorithms", "max_stars_repo_head_hexsha": "13a04cc4a6bd8dec5e35c1a42b96680d47a98962", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-10-12T19:16:53.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-01T03:13:05.000Z", "max_issues_repo_path": "mst.tex", "max_issues_repo_name": "SteamedPears/AllTheAlgorithms", "max_issues_repo_head_hexsha": "13a04cc4a6bd8dec5e35c1a42b96680d47a98962", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mst.tex", "max_forks_repo_name": "SteamedPears/AllTheAlgorithms", "max_forks_repo_head_hexsha": "13a04cc4a6bd8dec5e35c1a42b96680d47a98962", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 54.9444444444, "max_line_length": 83, "alphanum_fraction": 0.7499157398, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096227509861, "lm_q2_score": 0.9173026612812897, "lm_q1q2_score": 0.8403497949748778}} {"text": "\\section{Matrices}\nIn the previous section we described linear transformations in a rather abstract way: what they are, how they behave qualitatively and how they look like in 2- and 3-dimensions. In this section we introduce a numerical method of representing linear transformations: matrices.\n\n\\subsection{Linear transformation of basis vectors}\nRecall that any vector $\\vec{v}\\in\\Rs{n}$ can be written as a linear combination of basis vectors $\\vec{b}_{1}, \\vec{b}_{2}, \\dots, \\vec{b}_{n}$:\n\\begin{equation}\n\t\\vec{v} = \\sum\\limits_{i=1}^{n}\\alpha_{i}\\vec{b}_{i} = \\alpha_{1}\\vec{b}_{1} + \\alpha_{2}\\vec{b}_{2} + \\cdots + \\alpha_{n}\\vec{b}_{n}.\n\\end{equation}\n\nApplying a linear transformation $T$ on $\\vec{v}$ yields, using the properties of linear transformations,\n\\begin{align}\n\tT\\left(\\vec{v}\\right) &= T\\left(\\alpha_{1}\\vec{b}_{1} + \\alpha_{2}\\vec{b}_{2} + \\cdots + \\alpha_{n}\\vec{b}_{n}\\right)\\nonumber\\\\\n\t\\tikz[baseline=-0.5ex]{\\draw[-stealth, xred] (0,0) -- (1,0) node[pos=-0.1, anchor=east] {additivity}}\n\t\t\t\t\t\t &= T\\left(\\alpha_{1}\\vec{b}_{1}\\right) + T\\left(\\alpha_{2}\\vec{b}_{2}\\right) + \\cdots + T\\left(\\alpha_{n}\\vec{b}_{n}\\right)\\nonumber\\\\\n \\tikz[baseline=-0.5ex]{\\draw[-stealth, xblue] (0,0) -- (1,0) node[pos=-0.1, anchor=east] {scalability}}\n\t\t\t\t\t\t &= \\alpha_{1}T\\left(\\vec{b}_{1}\\right) + \\alpha_{2}T\\left(\\vec{b}_{2}\\right) + \\cdots + \\alpha_{n}T\\left(\\vec{b}_{n}\\right).\n\t\\label{eq:transfom_by_basis}\n\\end{align}\n\nThis result is pretty neat: it means that by knowing how a linear transformation $T$ changes the basis vectors, we know exactly how any vector is transformed by $T$. This true for any basis, and thus specifically to the standard basis, where the coefficients $\\alpha_{1},\\alpha_{2},\\dots,\\alpha_{n}$ are actually the components of the vector, i.e. $v_{1},v_{2},\\dots,v_{n}$. Thus in the standard basis:\n\\begin{equation}\n\tT\\left(\\vec{v}\\right) = v_{1}T\\left(\\eb{1}\\right) + v_{2}T\\left(\\eb{2}\\right) + \\cdots + v_{n}T\\left(\\eb{n}\\right).\n\\end{equation}\n\n\\begin{example}{Vector transformation via a basis}{}\n\tApplying the transformation $T:\\Rs{3}\\to\\Rs{3}$, defined as\n\t\\[\n\t\tT\\left(\\colvec{x;y;z}\\right)=\\colvec{x+y-2z;2x+z;-x-y-z}\n\t\\]\n\ton the vector $\\vec{v}=\\colvec{2;-1;3}$ yields the following vector:\n\t\\[\n\t\tT\\left(\\vec{v}\\right) = T\\left(\\colvec{2;-1;3}\\right) = \\colvec{2+(-1)-2\\cdot3;2\\cdot2+3;-2-(-1)-3} = \\colvec{2-1-6;4+3;-2+1-3} = \\colvec{-5;7;-4}.\n\t\\]\n\n\tNow, let us apply $T$ first to the three standard basis vectors $\\hat{x},\\hat{y},\\hat{z}$:\n\t\\begin{align*}\n\t\tT\\left( \\hat{x} \\right) &= T\\left(\\colvec{1;0;0}\\right) = \\colvec{1+0-\\cancel{2\\cdot0};2\\cdot1+0;-1-0-0} = \\colvec{1;2;-1},\\\\\n\t\tT\\left( \\hat{y} \\right) &= T\\left(\\colvec{0;1;0}\\right) = \\colvec{0+1-\\cancel{2\\cdot0};\\cancel{2\\cdot0}+0;-0-1-0} = \\colvec{1;0;-1},\\\\\n\t\tT\\left( \\hat{z} \\right) &= T\\left(\\colvec{0;0;1}\\right) = \\colvec{0+0-2\\cdot1;\\cancel{2\\cdot0}+1;-0-0-1} = \\colvec{-2;1;-1}.\n\t\\end{align*}\n\n\tTaking these results and applying \\autoref{eq:transfom_by_basis} yields\n\t\\begin{align*}\n\t\tT\\left( \\vec{v} \\right) &= 2T \\left( \\hat{x} \\right) -T \\left( \\hat{y} \\right) + 3T \\left( \\hat{z} \\right)\\\\\n\t\t\t\t\t\t\t\t&= 2\\colvec{1;2;-1} - \\colvec{1;0;-1} + 3\\colvec{-2;1;-1}\\\\\n\t\t\t\t\t\t\t\t&= \\colvec{2;4;-2} - \\colvec{1;0;-1} + \\colvec{-6;3;-3}\\\\\n\t\t\t\t\t\t\t\t&= \\colvec{2-1-6;4-0+3;-2-(-1)+(-3)}\\\\\n\t\t\t\t\t\t\t\t&= \\colvec{-5;7;-4},\n\t\\end{align*}\n\twhich is indeed what we got when we applied $T$ directly to $\\vec{v}$.\n\\end{example}\n\n\\subsection{From transformations to matrices}\nThe most general linear transformation $T:\\Rs{2}\\to\\Rs{2}$ has the following form:\n\\begin{equation}\n\tT \\left( \\colvec{x;y} \\right) = \\colvec{ax+by;cx+dy},\n\t\\label{eq:generic_R2_LT}\n\\end{equation}\nwhere $a,b,c,d\\in\\mathbb{R}$. If we apply this transformation to $\\hat{x}$ and $\\hat{y}$ we get, respectively,\n\\begin{equation}\n\tT \\left( \\hat{x} \\right) = \\colvec{a;c},\\quad T \\left( \\hat{y} \\right) = \\colvec{b;d}.\n\t\\label{eq:}\n\\end{equation}\nWe can now collect these two vectors to form a new structure, which we call a \\emph{matrix} (in this specific casr a $2\\times2$ matrix):\n\\begin{equation}\n\tA = \\begin{bNiceMatrix} a&b\\\\c&d \\end{bNiceMatrix}.\n\t\\label{eq:matrix}\n\\end{equation}\n\nWe then define the product of $M$ with a vector $\\vec{v}=\\colvec{x;y}$ to yield $T \\left( \\vec{v} \\right)$, i.e.\n\\begin{equation}\n\tA\\vec{v} = \\begin{bNiceMatrix} a&b\\\\c&d \\end{bNiceMatrix} \\cdot\\colvec{x;y} = \\colvec{ax+by;cx+dy}.\n\t\\label{eq:matrix_vector_product_2x2}\n\\end{equation}\nThis defintion can be re-written as following:\n\\begin{equation}\n\tA\\vec{v} = \\begin{bNiceMatrix} a&b\\\\c&d \\end{bNiceMatrix} \\cdot\\colvec{x;y} = \\colvec{A_{1}\\cdot\\vec{v};A_{2}\\cdot\\vec{v}},\n\t\\label{eq:matrix_vector_product_as_dot_product}\n\\end{equation}\ni.e. the $i$-th component of the resulting vector is the scalar product of the $i$-th \\textbf{row} of the matrix with the vector $\\vec{v}$.\n\n\\begin{example}{Matrix-vector product}{}\n\tSome matrix-vector products:\n\n\t\\begin{align*}\n\t\t\\begin{bNiceMatrix}\n\t\t\t1 & -2 \\\\\n\t\t\t0 & 5\n\t\t\\end{bNiceMatrix}\\colvec{-3;2} &= \\colvec{1\\cdot(-3) + (-2)\\cdot2;\\cancel{0\\cdot(-3)}+5\\cdot2} = \\colvec{-7;10},\\\\[5mm]\n\t\t\\begin{bNiceMatrix}\n\t\t\t1 & 2 \\\\\n\t\t\t1 & 2\n\t\t\\end{bNiceMatrix}\\colvec{5;-4} &= \\colvec{1\\cdot5+2\\cdot(-4);1\\cdot5+2\\cdot(-4)} = \\colvec{-3;-3},\\\\[5mm]\n\t\t\\begin{bNiceMatrix}\n\t\t\t1 & 0 \\\\\n\t\t\t0 & 2\n\t\t\\end{bNiceMatrix}\\colvec{2;-2} &= \\colvec{2\\cdot2+\\cancel{0\\cdot(-2)};\\cancel{0\\cdot2}+2\\cdot(-2)} = \\colvec{4;-4}.\n\t\\end{align*}\n\\end{example}\n\n\\begin{challenge}{Proof of linearity}{}\n\tProve that the transformation $T$ in \\autoref{eq:generic_R2_LT} is indeed linear.\n\\end{challenge}\n\nThe most general form of a linear transformation is $T:\\Rs{n}\\to\\Rs{m}$, i.e. a transformation which takes $n$-dimensional vectors as input and returns $m$-dimensional vectors as output:\n\\begin{equation}\n\tT \\left( \\colvec{\\tikzmark{N}x_{1};x_{2};\\vdots;x_{n}} \\right) = \\colvec{\n\t\t\\Ma{1}{1}x_{1}+\\Ma{1}{2}x_{2}+\\cdots+\\Ma{1}{n}x_{n};\n\t\t\\Ma{2}{1}x_{1}+\\Ma{2}{2}x_{2}+\\cdots+\\Ma{2}{n}x_{n}\\tikzmark{M};\n\t\t\\vdots;\n\t\t\\Ma{m}{1}x_{1}+\\Ma{m}{2}x_{2}+\\cdots+\\Ma{m}{n}x_{n}\n\t},\n\t\\label{eq:}\n\\end{equation}\n\\begin{tikzpicture}[overlay, remember picture]\n\t\\node[xblue] (Ntxt) at ($(pic cs:N)+(-1.5cm,-2mm)$) {$\\Rs{n}\\ni$};\n\t\\draw[-stealth, xblue] (Ntxt) to [out=45, in=90] ($(pic cs:N)+(1mm,2.5mm)$);\n\t\\node[xred] (Mtxt) at ($(pic cs:M)+(2.5cm,5mm)$) {$\\in\\Rs{m}$};\n\t\\draw[-stealth, xred] (Mtxt) to [out=180, in=0] ($(pic cs:M)+(2.5mm,0)$);\n\\end{tikzpicture}\n\nwhere $\\Ma{i}{j}\\in\\mathbb{R},\\ \\textcolor{xred}{i}=1,2,3,\\dots,m$ and $\\textcolor{xblue}{j}=1,2,3,\\dots,n$.\n\n\\begin{challenge}{Proof of linearity}{}\n\tProve that the above transformation $T$ is indeed linear.\n\\end{challenge}\n\nRespectively, we define an $\\textcolor{xred}{m}\\times \\textcolor{xblue}{n}$ matrix (\\textcolor{xred}{$m$} rows by \\textcolor{xblue}{$n$} columns) by collecting all the coefficients $\\Ma{i}{j}$ into a single structure:\n\\begin{equation}\n\tA =\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix}. \n\t\\label{eq:mxn_matrix}\n\\end{equation}\nThe product $M\\vec{v}$ (where $\\vec{v}\\in\\Rs{n}$) is then defined as\n\\begin{equation}\n\tA\\vec{v} =\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix}\\colvec{x_{1};x_{2};\\vdots;x_{n}} = \\colvec{\n\t\\Ma{1}{1}x_{1}+\\Ma{1}{2}x_{2}+\\cdots+\\Ma{1}{n}x_{n};\n\t\\Ma{2}{1}x_{1}+\\Ma{2}{2}x_{2}+\\cdots+\\Ma{2}{n}x_{n};\n\t\\vdots;\n\t\\Ma{m}{1}x_{1}+\\Ma{m}{2}x_{2}+\\cdots+\\Ma{m}{n}x_{n}\n\t}.\n\t\\label{eq:matrix_vector_product}\n\\end{equation}\nAgain, note that the $i$-th component of the resulting vector is the scalar product $A_{i}\\cdot\\vec{v}$.\n\n\\begin{note}{When is a matrix-vector product defined}{}\n\tIn order for a matrix-vector product to be defined, the vector must be of the same dimension as the number of \\textbf{columns} in the matrix - i.e. given an $a\\times b$ matrix, a vector must be $b$-dimensional for the product to be defined.\n\\end{note}\n\n\\begin{example}{Some matrix-vector products}{}\n\t\\blindtext[2]\n\\end{example}\n\nThe structure of an $m\\times n$ matrix $A$ has a nice property: given that the transformation in represented in some basis $B=\\left\\{ \\vec{b}_{1},\\vec{b}_{2},\\dots,\\vec{b}_{n} \\right\\}$, the $i$-th column of the matrix always shows how $\\vec{b}_{i}$ is transformed by the product $A\\vec{b}_{n}$. This is easy to see in the case of the standard basis, which we anyway use througout this chapter:\n\n\\vspace{1cm}\n\\begin{equation*}\n\t\\setlength{\\arraycolsep}{2.7mm}\n\tA =\n\t\\begin{bNiceMatrix}\n\t\t\\tikzmark{A1}\\Ma{1}{1} & \\tikzmark{B1}\\Ma{1}{2} & \\cdots & \\tikzmark{N1}\\Ma{1}{n}\\\\\n\t \\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\ddots & \\vdots\\\\\n\t\t\\Ma{m}{1}\\tikzmark{A2} & \\Ma{m}{2}\\tikzmark{B2} & \\cdots & \\Ma{m}{n}\\tikzmark{N2}\n\t\\end{bNiceMatrix}.\n\\end{equation*}\n\\tikzset{\n\thighlight/.style={thick, draw=#1, rounded corners, draw opacity=1, fill=#1, fill opacity=0.2},\n\thltxt/.style={highlight=#1, draw opacity=1, text=black, text opacity=1, above, yshift=1.5cm},\n\tnrtxt/.style={black, opacity=1, text opacity=1},\n\thlarrow/.style={-stealth, thick, #1},\n}\n\\tikz[overlay, remember picture, blend mode=multiply]{\n\t\\draw[highlight={xgreen}] ($(pic cs:A1)+(-2pt,7pt)$) rectangle node[hltxt={xgreen} ](Atxt){$T \\left( \\eb{1} \\right)$}($(pic cs:A2)+(2pt,-5pt)$);\n\t\\draw[highlight={xpurple}] ($(pic cs:B1)+(-2pt,7pt)$) rectangle node[hltxt={xpurple}](Btxt){$T \\left( \\eb{2} \\right)$}($(pic cs:B2)+(2pt,-5pt)$);\n\t\\draw[highlight={xorange}] ($(pic cs:N1)+(-2pt,7pt)$) rectangle node[hltxt={xorange}](Ntxt){$T \\left( \\eb{n} \\right)$}($(pic cs:N2)+(2pt,-5pt)$);\n\n\t\\draw[hlarrow={xgreen}] (Atxt.south) -- ++(0,-5mm);\n\t\\draw[hlarrow={xpurple}] (Btxt.south) -- ++(0,-5mm);\n\t\\draw[hlarrow={xorange}] (Ntxt.south) -- ++(0,-5mm);\n}\n\n\\begin{example}{Matrices}{}\n\tThe product of the following matrix $A$ with each of the vectors $\\eb{1},\\eb{2},\\eb{3}$ (i.e. $\\hat{x},\\hat{y}$ and $\\hat{z}$, respectively) returns the respective column of the matrix:\n\t\\begin{align*}\n\t\tA\\eb{1}=\n\t\t\\begin{bNiceMatrix}\n\t\t\t 1 & 2 & 0\\\\\n\t\t\t-1 & 3 & 4\\\\\n\t\t\t 0 & 1 & 3\\\\\n\t\t \\end{bNiceMatrix}\\colvec{1;0;0} &= \\colvec{1\\cdot1+\\cancel{2\\cdot0}+\\cancel{\\cancel{0\\cdot0}};-1\\cdot1+\\cancel{3\\cdot0}+\\cancel{4\\cdot0};\\cancel{0\\cdot1}+\\cancel{1\\cdot0}+\\cancel{3\\cdot0}} = \\colvec{1;-1;0},\\\\[3mm]\n\t\tA\\eb{2}=\n\t\t\\begin{bNiceMatrix}\n\t\t\t 1 & 2 & 0\\\\\n\t\t\t-1 & 3 & 4\\\\\n\t\t\t 0 & 1 & 3\\\\\n\t\t\\end{bNiceMatrix}\\colvec{0;1;0} &= \\colvec{\\cancel{1\\cdot0}+2\\cdot1+\\cancel{\\cancel{0\\cdot0}};-\\cancel{1\\cdot0}+3\\cdot1+\\cancel{4\\cdot0};\\cancel{\\cancel{0\\cdot0}}+1\\cdot1+\\cancel{3\\cdot0}} = \\colvec{2;3;1},\\\\[3mm]\n\t\tA\\eb{3}=\n\t\t\\begin{bNiceMatrix}\n\t\t\t 1 & 2 & 0\\\\\n\t\t\t-1 & 3 & 4\\\\\n\t\t\t 0 & 1 & 3\\\\\n\t\t\\end{bNiceMatrix}\\colvec{0;0;1} &= \\colvec{\\cancel{1\\cdot0}+\\cancel{2\\cdot0}+\\cancel{0\\cdot1};-\\cancel{1\\cdot0}+\\cancel{3\\cdot0}+4\\cdot1;\\cancel{\\cancel{0\\cdot0}}+\\cancel{1\\cdot0}+3\\cdot1} = \\colvec{0;4;3}.\n\t\\end{align*}\n\\end{example}\n\n\\subsection{Matrix representation of the basic linear transformations (2D)}\nWe can now represent all of the basic linear transformations in $\\Rs{2}$ mentioned in the previous section (\\autoref{fig:basicLinearTrans}) as $2\\times2$ matrices. We do this by observing how the basis vectors $\\hat{x}$ and $\\hat{y}$ change after the application of each transformation.\n\n\\begin{descitemize}\n\t\\item[Identity] both basis vectors remain the same: $\\colvec{1;0}\\to\\colvec{1;0},\\ \\colvec{0;1}\\to\\colvec{0;1}$. Therefore the matrix $I$ representing the identity transformation is\n\t\t\\begin{equation}\n\t\t\tI = \\begin{bNiceMatrix} 1&0 \\\\ 0&1 \\end{bNiceMatrix}.\n\t\t\\end{equation}\n\n\t\\item[Scaling by $\\bm{s}$ in the $\\bm{x}$-direction] the basis vector $\\hat{x}$ is streched by $s$: $\\colvec{1;0}\\to\\colvec{s;0}$. The basis vector $\\hat{y}=\\colvec{0;1}$ stays the same. Therefore the matrix $S_{x}$ representing the transformation is\n\t\t\\begin{equation}\n\t\t\tS_{x} = \\begin{bNiceMatrix} s&0 \\\\ 0&1 \\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\t\n\t\\item[Scaling by $\\bm{s}$ in the $\\bm{y}$-direction] much like with $S_{x}$, now the basis vector $\\hat{y}$ is the one getting streched, by $\\beta$: $\\colvec{0;1}\\to\\colvec{0;s}$. The basis vector $\\hat{x}=\\colvec{1;0}$ stays the same. Therefore the matrix $S_{y}$ representing the transformation is\n\t\t\\begin{equation}\n\t\t\tS_{y} = \\begin{bNiceMatrix} 1&0 \\\\ 0&s \\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\n\t\\item[Rotating by $\\bm{\\theta}$ counter-clockwise about the origin] \\autoref{fig:rotationT} shows how do $\\hat{x}$ and $\\hat{y}$ transformed by the rotation. In the case of $\\hat{x}$, the resulting vector is $R_{\\theta} \\left( \\hat{x} \\right)=\\colvec{\\cos(\\theta),\\sin(\\theta)}$, since thiese are the respective sides of a right triangle of hypotenous $1$ and angle $\\theta$. The components of $R_{\\theta}\\left(\\hat{y}\\right)$ can be calculated by rotating $\\hat{x}$ by $\\theta+\\frac{\\pi}{2}$ ($\\theta+\\ang{90}$): $\\cos \\left( \\theta+\\frac{\\pi}{2} \\right) = -\\sin(\\theta)$, and $\\sin \\left( \\theta+\\frac{\\pi}{2} \\right) = \\cos \\left( \\theta \\right)$. Therefore we get\n\t\t\\begin{equation}\n\t\t\t\\colvec{1;0} \\to \\colvec{\\cos(\\theta);\\sin(\\theta)},\\ \\colvec{0;1} \\to \\colvec{-\\sin(\\theta);\\cos(\\theta)}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\n\t\tAltogether the rotation matrix $R_{\\theta}$ is\n\t\t\\begin{equation}\n\t\t\tR_{\\theta} = \\begin{bNiceMatrix} \\cos(\\theta)&-\\sin(\\theta) \\\\ \\sin(\\theta)&\\cos(\\theta) \\end{bNiceMatrix}.\n\t\t\t\\label{eq:2D_rotation_matrix}\n\t\t\\end{equation}\n\n\t\t\\begin{figure}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tvector plane,\n\t\t\t\t\twidth=10cm, height=10cm,\n\t\t\t\t\txmin=-1.3, xmax=1.3,\n\t\t\t\t\tymin=-1.3, ymax=1.3,\n\t\t\t\t\txtick={-1,0,1},\n\t\t\t\t\tytick={-1,0,1},\n\t\t\t\t\tyticklabel pos=right,\n\t\t\t\t\tyticklabel style={anchor=west},\n\t\t\t\t]\n\t\t\t\t\\pgfmathsetmacro{\\t}{30};\n\t\t\t\t\\draw[black!20] (1,0) arc (0:360:1);\n\t\t\t\t\\tikzset{point/.style={circle, fill=#1, inner sep=0pt, minimum size=3pt}}\n\n\t\t\t\t% x\n\t\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[midway, below] {$\\hat{x}$};\n\t\t\t\t\\draw[vector, xred, dashed] (0,0) -- ({cos(\\t)},{sin(\\t)}) node[midway, above, rotate=\\t] {$R_{\\theta} \\left( \\hat{x} \\right)$};\n\t\t\t\t\\fill[xpurple, opacity=0.15] (0,0) -- (1,0) arc (0:\\t:1) -- cycle;\n\t\t\t\t\\draw[vector, xpurple, dashed] (1,0) arc (0:\\t:1) node[point={xred}] (rx) {};\n\t\t\t\t\\node[text=xpurple] at ({1.1*cos(\\t/2)},{1.1*sin(\\t/2)}) {$\\theta$};\n\t\t\t\t\n\t\t\t\t% y\n\t\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[midway, right] {$\\hat{y}$};\n\t\t\t\t\\draw[vector, xblue, dashed] (0,0) -- ({-sin(\\t)},{cos(\\t)}) node[midway, below, rotate={\\t-90}] {$R_{\\theta} \\left( \\hat{y} \\right)$};\n\t\t\t\t\\fill[xpurple, opacity=0.15] (0,0) -- (0,1) arc (90:{90+\\t}:1) -- cycle;\n\t\t\t\t\\draw[vector, xpurple, dashed] (0,1) arc (90:{90+\\t}:1) node[point={xblue}] (ry) {};\n\t\t\t\t\\node[text=xpurple] at ({-1.1*sin(\\t/2)},{1.1*cos(\\t/2)}) {$\\theta$};\n\t\t\t\t\\end{axis}\n\t\t\t\t\\node[xred, anchor=west, yshift=5pt] at (rx) {$\\left( \\Ctrig,\\Strig \\right)$};\n\t\t\t\t\\node[xblue, anchor=east, xshift=-4pt] at (ry) {$\\left( -\\Strig,\\Ctrig \\right)$};\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Rotation of $\\textcolor{xred}{\\hat{x}}$ and $\\textcolor{xblue}{\\hat{y}}$ by an angle $\\textcolor{xpurple}{\\theta}$ counter-clockwise about the origin. The notations $\\Ctrig,\\Strig$ stand for $\\cos(\\textcolor{xpurple}{\\theta})$ and $\\sin(\\textcolor{xpurple}{\\theta})$, respectively.}\n\t\t\t\\label{fig:rotationT}\n\t\t\\end{figure}\n\t\n\t\\item[Skew by $\\bm{k}$ in the $\\bm{x}$-direction] what differentiates this transformation from scaling in the $x$-direction is that a skew changes only $\\hat{y}$ by adding to it some horizontal displacement $\\vec{K}=k\\hat{x}$ (see \\autoref{fig:skew_in_x}). Therefore $\\hat{x}$ remains the same while $\\hat{y}$ is transformed as $\\hat{y}\\to\\hat{y}+\\vec{k}=\\hat{y}+k\\hat{x}=\\colvec{0;1}+\\colvec{k;0}=\\colvec{k;1}$, and altogether the matrix is\n\t\t\\begin{equation}\n\t\t\tK_{x} = \\begin{bNiceMatrix} 1&k \\\\ 0&1 \\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\t\t\n\t\t\\begin{figure}\n\t\t\t\\centering\n\t\t\t\\begin{tikzpicture}\n\t\t\t\t\\begin{axis}[\n\t\t\t\t\tvector plane,\n\t\t\t\t\twidth=10cm, height=10cm,\n\t\t\t\t\txmin=-1.3, xmax=1.3,\n\t\t\t\t\tymin=-1.3, ymax=1.3,\n\t\t\t\t\tticks=none,\n\t\t\t\t]\n\t\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[midway, below] {$\\hat{x}, K_{x}\\left(\\hat{x}\\right)$};\n\t\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[midway, right] {$\\hat{y}$};\n\t\t\t\t\\draw[vector, xblue, dashed] (0,0) -- (0.5,1) node[midway, right] {$K_{x}\\left( \\hat{y} \\right)$};\n\t\t\t\t\\draw[vector, xpurple, dashed] (0,1) -- (0.5,1) node [midway, above] {$\\vec{k}=k\\hat{x}$};\n\t\t\t\t\\end{axis}\n\t\t\t\\end{tikzpicture}\n\t\t\t\\caption{Skew in the $x$-direction.}\n\t\t\t\\label{fig:skew_in_x}\n\t\t\\end{figure}\n\n\t\\item[Skew by $\\bm{k}$ in the $\\bm{y}$-direction] same idea, except the roles of the axes are reveresed:\n\t\t\\[\n\t\t\t\\colvec{1;0}\\to\\colvec{1;k},\\ \\colvec{0;1}\\to\\colvec{0;1}.\n\t\t\\]\n\t\tThus the matrix is\n\t\t\\begin{equation}\n\t\t\tK_{y} = \\begin{bNiceMatrix} 1&0 \\\\ k&1 \\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\n\t\\item[Reflections across a line going through the origin] in the case of reflections across the $x$-axis, $\\hat{x}$ stays the same, while $\\hat{y}$ is flipped (see \\autoref{fig:ref_x_axis}), i.e. $\\colvec{0;1}\\to-\\colvec{0;1}=\\colvec{0;-1}$. Therefore the matrix is\n\t\t\\begin{equation}\n\t\t\t\\Refl_{x} = \\begin{bNiceMatrix} 1&0 \\\\ 0&-1 \\end{bNiceMatrix}.\n\t\t\\end{equation}\n\t\t\n\t\tSimilarily, a reflection across the $y$-axis flipps $\\hat{x}$ while keeping $\\hat{y}$ the same (see \\autoref{fig:ref_y_axis}), i.e.\n\t\t\\begin{equation}\n\t\t\t\\Refl_{y} = \\begin{bNiceMatrix} -1&0 \\\\ 0&1 \\end{bNiceMatrix}. \n\t\t\\end{equation}\n\t\t\n\t\tAnother special case of these kinds of reflections is done across the line rotated by $\\frac{\\pi}{4}=\\ang{45}$ relative to the $x$-axis, i.e the line $y=x$. In this case $\\hat{x}$ and $\\hat{y}$ are swapped, giving\n\t\t\\begin{equation}\n\t\t\t\\Refl_{\\frac{\\pi}{4}} = \\begin{bNiceMatrix} 0&1 \\\\ 1&0 \\end{bNiceMatrix}. \n\t\t\\end{equation}\n\n\t\tThe most general reflection is made across a line of angle $\\theta$ relative to the $x$-axis (see \\autoref{fig:ref_line}):\n\t\t\\begin{equation}\n\t\t\t\\Refl_{\\theta} = \\begin{bNiceMatrix} \\cos \\left( 2\\theta \\right) & \\sin \\left( 2\\theta \\right) \\\\ \\sin \\left( 2\\theta \\right) & -\\cos \\left( 2\\theta \\right) \\end{bNiceMatrix}.\n\t\t\t\\label{eq:reflect_general_2x2}\n\t\t\\end{equation}\n\t\tA way to calculate this matrix will be shown later in the chapter.\n\n\t\tWe can translate the matrix to be based on the slope $m$ of the line instead of its angle $\\theta$ relative to the $x$-axis by using the relation $m=\\tan\\left(\\theta\\right)$ and the two trigonomentric identities for double angles (\\autoref{eq:tan_double_angles}):\n\t\t\\begin{align*}\n\t\t\t\\begin{bNiceMatrix} \\cos \\left( 2\\theta \\right) & \\sin \\left( 2\\theta \\right) \\\\ \\sin \\left( 2\\theta \\right) & -\\cos \\left( 2\\theta \\right) \\end{bNiceMatrix} &= \\begin{bNiceMatrix} \\frac{1-\\tan^{2} \\left( \\theta \\right) }{1+\\tan^{2} \\left( \\theta \\right) } & \\frac{2\\tan \\left( \\theta \\right) }{1+\\tan^{2} \\left( \\theta \\right) } \\\\ \\frac{2\\tan \\left( \\theta \\right) }{1+\\tan^{2} \\left( \\theta \\right) } & \\frac{\\tan^{2} \\left( \\theta \\right)-1 }{1+\\tan^{2} \\left( \\theta \\right) } \\end{bNiceMatrix}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t&= \\frac{1}{1+\\tan^{2} \\left( \\theta \\right)}\\begin{bNiceMatrix} 1-\\tan^{2} \\left( \\theta \\right) & 2\\tan \\left( \\theta \\right) \\\\ 2\\tan \\left( \\theta \\right) & \\tan^{2} \\left( \\theta \\right) -1 \\end{bNiceMatrix}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t&= \\frac{1}{1+m^{2}} \\begin{bNiceMatrix} 1-m^{2} & 2m \\\\ 2m & m^{2}-1 \\end{bNiceMatrix}.\n\t\t\\end{align*}\t\n\n\t\t\\begin{figure}\n\t\t\t\\centering\n\t\t\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\t\\begin{center}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tvector plane,\n\t\t\t\t\t\twidth=8cm, height=8cm,\n\t\t\t\t\t\txmin=-1.5, xmax=1.5,\n\t\t\t\t\t\tymin=-1.5, ymax=1.5,\n\t\t\t\t\t\tticks=none,\n\t\t\t\t\t]\n\t\t\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[below] {$\\hat{x},\\ \\Refl_{x}\\left(\\hat{x}\\right)$};\n\t\t\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[right] {$\\hat{y}$};\n\t\t\t\t\t\\draw[vector, xblue, dashed] (0,0) -- (0,-1) node[right] {$\\Refl_{x}\\left(\\hat{y}\\right)$};\n\t\t\t\t\t\\end{axis}\n\t\t\t\t\\end{tikzpicture}\t\n\t\t\t\\end{center}\n\t\t\t\\caption{Reflection across the $x$-axis.}\n\t\t\t\\label{fig:ref_x_axis}\n\t\t\t\\end{subfigure}\n\t\t\t\\hfill\n\t\t\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\t\\begin{center}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tvector plane,\n\t\t\t\t\t\twidth=8cm, height=8cm,\n\t\t\t\t\t\txmin=-1.5, xmax=1.5,\n\t\t\t\t\t\tymin=-1.5, ymax=1.5,\n\t\t\t\t\t\tticks=none,\n\t\t\t\t\t]\n\t\t\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[below] {$\\hat{x}$};\n\t\t\t\t\t\\draw[vector, xred, dashed] (0,0) -- (-1,0) node[below] {$\\Refl_{y}\\left(\\hat{x}\\right)$};\n\t\t\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[right] {$\\hat{y},\\ \\Refl_{y}\\left(\\hat{y}\\right)$};\n\t\t\t\t\t\\end{axis}\n\t\t\t\t\\end{tikzpicture}\t\n\t\t\t\\end{center}\n\t\t\t\\caption{Reflection across the $y$-axis.}\n\t\t\t\\label{fig:ref_y_axis}\n\t\t\t\\end{subfigure}\n\t\t\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\t\\begin{center}\n\t\t\t\t\\begin{tikzpicture}\n\t\t\t\t\t\\begin{axis}[\n\t\t\t\t\t\tvector plane,\n\t\t\t\t\t\twidth=8cm, height=8cm,\n\t\t\t\t\t\txmin=-1.5, xmax=1.5,\n\t\t\t\t\t\tymin=-1.5, ymax=1.5,\n\t\t\t\t\t\tticks=none,\n\t\t\t\t\t]\n\t\t\t\t\t% original vectors\n\t\t\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[below] {$\\hat{x}$};\n\t\t\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[right] {$\\hat{y}$};\n\t\t\t\t\t\n\t\t\t\t\t% reflection line\n\t\t\t\t\t\\draw[thick, black!75, dashed] (-1.5,-0.5) -- (1.5,0.5);\n\n\t\t\t\t\t% reflected vectors\n\t\t\t\t\t\\draw[vector, xred, dashed] (0,0) -- (0.8,0.6) node[below, anchor=west, yshift=5pt] {$\\Refl_{\\theta}\\left(\\hat{x}\\right)$};\n\t\t\t\t\t\\draw[vector, xblue, dashed, anchor=west] (0,0) -- (0.6,-0.8) node[right] {$\\Refl_{\\theta}\\left(\\hat{y}\\right)$};\n\n\t\t\t\t\t% angles\n\t\t\t\t\t\\fill[xpurple, opacity=0.2] (0,0) -- (0.5,0) arc (0:18.435:0.5) node (A) {} -- cycle;\n\t\t\t\t\t\\fill[xgreen, opacity=0.2] (0,0) -- (A) arc (18.435:36.87:0.5) -- (0,0);\n\t\t\t\t\t\\fill[xpurple, opacity=0.2] (0,0) -- (0,0.5) arc (90:198.435:0.5) node (B) {} -- cycle;\n\t\t\t\t\t\\fill[xgreen, opacity=0.2] (0,0) -- (B) arc (198.435:306.87:0.5) -- (0,0);\n\t\t\t\t\t\\end{axis}\n\t\t\t\t\\end{tikzpicture}\t\n\t\t\t\\end{center}\n\t\t\t\\caption{Reflection across a line going through the origin. Notice how in both cases the purple and green angles are the same: this shows that both $\\hat{x}$ and $\\hat{y}$ are reflected across the line.}\n\t\t\t\\label{fig:ref_line}\n\t\t\t\\end{subfigure}\n\t\t\t\\caption{Reflections across different lines going through the origin.}\n\t\t\t\\label{fig:reflections}\n\t\t\\end{figure}\n\t\t\n\t\\item[Reflection across the origin] in this case both $\\hat{x}$ and $\\hat{y}$ are flipped, i.e.\n\t\t\\[\n\t\t\t\\colvec{1;0}\\to\\colvec{-1;0},\\ \\colvec{0;1}\\to\\colvec{0;-1},\n\t\t\\]\n\t\tand the matrix is essentially a rotation by $\\pi$ ($\\ang{180}$) around the origin:\n\t\t\\begin{equation}\n\t\t\tR = \\begin{bNiceMatrix} -1&0 \\\\ 0&-1 \\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\\end{descitemize}\n\nTable \\autoref{tab:matrix_basic_LTs} summarizes all the matrices of the basic linear transformations.\n\n\\begin{longtable}{lcccc}\n\t% !!! vvv MUST FIND WHY THESE DON'T WORK vvv !!! %\n\t% \\caption{my caption}\\\\\n\t% \\label{tab:matrix_basic_LTs}\n\t% !!! ^^^ THESE TWO LINES ^^^ !!! %\n\t\\toprule\n\tTransformation & Trans Tapir & $T \\left( \\hat{x} \\right)$ & $T \\left( \\hat{y} \\right)$ & Matrix\\\\\n\t\\midrule\n\tIdentity & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1}{0}{0}{1}{0}{0}{}} & $\\colvec{1;0}$ & $\\colvec{0;1}$ & $\\begin{bNiceMatrix} 1&0 \\\\ 0&1 \\end{bNiceMatrix}$\\\\\n\tScale in $x$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1.3}{0}{0}{1}{0}{0}{}} & $\\colvec{s;0}$ & $\\colvec{0;1}$ & $\\begin{bNiceMatrix} s&0 \\\\ 0&1 \\end{bNiceMatrix}$\\\\\n\tScale in $y$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1}{0}{0}{1.4}{0}{0}{}} & $\\colvec{1;0}$ & $\\colvec{0;s}$ & $\\begin{bNiceMatrix} 1&0 \\\\ 0&s \\end{bNiceMatrix}$\\\\\n\tRotation & \\tikz[baseline=-0.5ex]{\\tapirTransComp{0.866}{0.5}{-0.5}{0.866}{0}{0}{}} & $\\colvec{\\Ctrig;-\\Strig}$ & $\\colvec{\\Strig;\\Ctrig}$ & $\\begin{bNiceMatrix} \\Ctrig & -\\Strig \\\\ \\Strig & \\Ctrig \\end{bNiceMatrix}$\\\\\n\tSkew in $x$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1}{0}{0.5}{1}{0}{0}{}} & $\\colvec{1;0}$ & $\\colvec{k;1}$ & $\\begin{bNiceMatrix} 1&0 \\\\ k&1 \\end{bNiceMatrix}$\\\\\n\tSkew in $y$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1}{0.35}{0}{1}{0}{0}{}} & $\\colvec{1;k}$ & $\\colvec{0;1}$ & $\\begin{bNiceMatrix} 1&k \\\\ 0&1 \\end{bNiceMatrix}$\\\\\n\tReflection by $x$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{1}{0}{0}{-1}{0}{0}{}} & $\\colvec{1;0}$ & $\\colvec{0;-1}$ & $\\begin{bNiceMatrix} 1&0 \\\\ 0&-1 \\end{bNiceMatrix}$\\\\\n\tReflection by $y$ & \\tikz[baseline=-0.5ex]{\\tapirTransComp{-1}{0}{0}{1}{0}{0}{}} & $\\colvec{-1;0}$ & $\\colvec{0;1}$ & $\\begin{bNiceMatrix} -1&0 \\\\ 0&1 \\end{bNiceMatrix}$\\\\\n\tReflection by line & \\tikz[baseline=-0.5ex]{\\tapirTransComp{0.882}{0.471}{0.471}{-0.882}{0}{0}{};\\draw[very thick, dashed, xpurple](-2,-0.5)--(2,0.5)node[pos=-0.05, anchor=east] {$y=mx$}} & $\\colvec{\\Ctrig_{2};\\Strig_{2}}$ & $\\colvec{\\Strig_{2};-\\Ctrig_{2}}$ & $\\begin{bNiceMatrix} \\Ctrig_{2}&\\Strig_{2} \\\\ \\Strig_{2}&-\\Ctrig_{2} \\end{bNiceMatrix}$\\\\\n\tReflection about origin & \\tikz[baseline=-0.5ex]{\\tapirTransComp{-1}{0}{0}{-1}{0}{0}{}} & $\\colvec{-1;0}$ & $\\colvec{0;-1}$ & $\\begin{bNiceMatrix} -1&0 \\\\ 0&-1 \\end{bNiceMatrix}$\\\\\n\t\\bottomrule\n\\end{longtable}\n\n\\subsection{Matrix representation of the basic linear transformations (3D)}\nIn 3-dimensions, the respective matrices are very similar. For example, the matrix for scaling by $\\alpha$ in the $x$-direction, $\\beta$ in the $y$-direction and $\\gamma$ in the $z$-direction is\n\\begin{equation}\n\tS = \n\t\\begin{bNiceMatrix}\n\t\t\\alpha & 0 & 0\\\\\n\t\t0 & \\beta & 0\\\\\n\t\t0 & 0 & \\gamma\n\t\\end{bNiceMatrix}.\n\t\\label{eq:3d_scale_matrix}\n\\end{equation}\n\nAs mentioned in the previous section, in 3-dimensions there are infinitely many rotations: the axis of rotation can be any line going through the origin (i.e. any vector except $\\vec{0}$ can represent an axis of rotation). Let us start with constructing rotations around the three axes $x,y$ and $z$ first. When rotating around the $x$ axis it stays stationary, while the rotation itself is done in the $yz$-plane. This means that we can take the $2\\times2$ rotation matrix (\\autoref{eq:2D_rotation_matrix}) and expand it such that it affects only the $yz$-plane:\n\n\\vspace{2em}\n\\begin{equation}\n\tR^{x}_{\\theta} =\n\t\\begin{bNiceMatrix}\n\t\t\\tikzmark{D1}1 & 0 & 0\\\\\n\t\t0 & \\tikzmark{E1} \\cos \\left( \\theta \\right) & -\\sin \\left( \\theta \\right) \\\\\n\t\t0\\tikzmark{D2} & \\sin \\left( \\theta \\right) & \\cos \\left( \\theta \\right)\\tikzmark{E2}\n\t\\end{bNiceMatrix}.\n\t\\label{eq:rotation_matrix_x}\n\\end{equation}\n\\begin{tikzpicture}[overlay, remember picture, blend mode=multiply]\n\t\\small\n\t\\draw[highlight={xred}] ($(pic cs:D1)+(-4pt,9pt)$) rectangle node[hltxt={xred}, above right, anchor=east, xshift=-1cm] (Atxt) {$\\hat{x}$ doesn't change} ($(pic cs:D2)+(4pt,-5pt)$);\n\t\\draw[hlarrow={xred}] (Atxt.east) to [out=0, in=90] ($(pic cs:D1) + (3pt,10pt)$);\n\t\\draw[highlight={xgreen}] ($(pic cs:E1)+(-4pt,9pt)$) rectangle node[hltxt={xgreen}, below left, anchor=west, yshift=-3cm, xshift=9mm] (Btxt) {2D rotation matrix} ($(pic cs:E2)+(4pt,-5pt)$);\n\t\\draw[hlarrow={xgreen}] (Btxt.west) to [out=180, in=-90] ($(pic cs:E1) + (35pt,-20pt)$);\n\\end{tikzpicture}\n\n\\vspace{3em}\nA graphical representation of the rotation can be seen in \\autoref{fig:rotation_in_yz}.\n\n\\begin{figure}\n\t\\centering\n\t\\def\\angThe{75}\n\t\\def\\angPhi{45}\n\t\\tdplotsetmaincoords{\\angThe}{\\angPhi}\n\t\\begin{tikzpicture}[tdplot_main_coords]\n\t\t\\draw[stealth-, very thick] (-3,0,0) -- (0,0,0);\n\t\t\\begin{scope}[canvas is yz plane at x=0]\n\t\t\t\\fill[fill=xgreen, fill opacity=0.2] (-2,2) -- (2,2) -- (2,-2) -- (-2,-2) -- cycle;\n\t\t\t\\draw[step=0.5, xdarkgreen!30] (-2,-2) grid (2,2);\n\t\t\t\\draw[vector, xgreen] (-1,0) arc (180:350:1);\n\t\t\t\\draw[vector, xgreen] (1,0) arc (0:170:1);\n\t\t\\end{scope}\n\t\t\\draw[stealth-stealth, very thick] (0,-3,0) -- (0,3,0) node[pos=1.05] {$y$};\n\t\t\\draw[stealth-stealth, very thick] (0,0,-3) -- (0,0,3) node[pos=1.05] {$z$};\n\t\t\\begin{scope}[canvas is yz plane at x=2]\n\t\t\t\\draw[vector, xgreen] (-0.5,0) arc (180:350:0.5);\n\t\t\\end{scope}\n\t\t\\draw[-stealth, very thick] (0,0,0) -- (3,0,0) node[pos=1.05] {$x$};\n\t\t\\begin{scope}[canvas is yz plane at x=2]\n\t\t\t\\draw[vector, xgreen] (0.5,0) arc (0:170:0.5);\n\t\t\\end{scope}\n\t\\end{tikzpicture}\n\t\\caption{In $\\Rs{3}$, rotation around the $x$-axis is a rotation in the $yz$-plane (i.e. $x=0$).}\n\t\\label{fig:rotation_in_yz}\n\\end{figure}\n\nThe rotation matrices around the $y$- and $z$-axes follow the same structure:\n\\begin{align}\n\tR^{y}_{\\varphi} &=\n\t\t\\begin{bNiceMatrix}\n\t\t\t\\cos \\left( \\varphi \\right) & 0 & \\sin \\left( \\varphi \\right)\\\\\n\t\t\t0 & 1 & 0 \\\\\n\t\t\t-\\sin \\left( \\varphi \\right) & 0 & \\cos \\left( \\varphi \\right)\n\t\t\\end{bNiceMatrix},\\\\\n\tR^{z}_{\\psi} &=\n\t\t\\begin{bNiceMatrix}\n\t\t\t\\cos \\left( \\psi \\right) & -\\sin \\left( \\psi \\right) & 0\\\\\n\t\t\t\\sin \\left( \\psi \\right) & \\cos \\left( \\psi \\right) & 0\\\\\n\t\t\t0 & 0 & 1\n\t\t\\end{bNiceMatrix}.\n\t\\label{eq:rotation_y_z}\n\\end{align}\n\n\\begin{note}{Direction of the $y$-axis}{}\n\tThe signs of $\\sin \\left( \\varphi \\right)$ in $R^{y}_{\\varphi}$ are flipped compared to $R^{x}_{\\theta}$ and $R^{z}_{\\psi}$, for the same reason a similar thing happens in the $y$-component of the cross product: it is due to the use of a right-handed system.\n\\end{note}\n\nThe most general rotation in $\\Rs{3}$, i.e. around an axis represented by the unit vector $\\hat{u}=\\colvec{u_{x};u_{y};u_{z}}$ counter-clockwise by an angle $\\theta$, is given in matrix form as\n\\begin{equation}\n\tR_{\\theta}=\n\t\\begin{bNiceMatrix}\n\t\t\\cos \\left( \\theta \\right) +u_{x}^{2}\\left[1-\\cos \\left( \\theta \\right) \\right] & u_{x}u_{y}\\left[1-\\cos \\left( \\theta \\right) \\right]-u_{z}\\sin \\left( \\theta \\right) & u_{x}u_{z}\\left[1-\\cos \\left( \\theta \\right) \\right]+u_{y}\\sin \\left( \\theta \\right) \\\\\n\t\tu_{y}u_{x}\\left[1-\\cos \\left( \\theta \\right) \\right]+u_{z}\\sin \\left( \\theta \\right) & \\cos \\left( \\theta \\right) +u_{y}^{2}\\left[1-\\cos \\left( \\theta \\right) \\right] & u_{y}u_{z}\\left[1-\\cos \\left( \\theta \\right) \\right]-u_{x}\\sin \\left( \\theta \\right) \\\\\n\t\tu_{z}u_{x}\\left[1-\\cos \\left( \\theta \\right) \\right]-u_{y}\\sin \\left( \\theta \\right) & u_{z}u_{y}\\left[1-\\cos \\left( \\theta \\right) \\right]+u_{x}\\sin \\left( \\theta \\right) & \\cos \\left( \\theta \\right) +u_{z}^{2}\\left[1-\\cos \\left( \\theta \\right) \\right]\\end{bNiceMatrix}.\n\t\\label{eq:}\n\\end{equation}\nFor the moment the derivation of this matrix is not presented.\n\nTBW: REFLECTIONS IN 3D.\n\n\\subsection{Matrix operations}\nAn important operation that can be performed on a matrix is the \\emph{transpose}: this operation \"rotates\" all rows of the matrix to columns, and wise-versa:\n\\begin{equation}\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix}\n\t\\xrightarrow[] {\\text{transpose}}\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{2}{1} & \\cdots & \\Ma{n}{1}\\\\\n\t\t\\Ma{1}{2} & \\Ma{2}{2} & \\cdots & \\Ma{n}{2}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{1}{m} & \\Ma{2}{m} & \\cdots & \\Ma{n}{m}\n\t\\end{bNiceMatrix}.\n\t\\label{eq:transpose}\n\\end{equation}\nMathematically, the transpose takes any element $\\Ma{i}{j}$ of the matrix and exchanges its indeces, yielding $\\Ma{j}{i}$. If the original matrix has dimensions $\\rhl{m}\\times \\bhl{n}$, then the transposed matrix has dimensions $\\rhl{n}\\times \\bhl{m}$. The notation for the transpose of a matrix $A$ is $A^{\\top}$.\n\n\\begin{example}{Transposing matrices}{}\n\tThe following presents three matrices each with its transpose. The elements in each matrix on the left hand side are highlighted column-wise, and these colors remain with the elements after the transpose. That way, the effect of the transpose is clear: columns in the original matrix become rows in the transposed matrix and vice-versa. In addition, the dimensions of each matrix are written below it.\n\n\t\\begin{align*}\n\t\t\\begin{bNiceMatrix}[name=T1]\n\t\t\t1 & 2 & 3\\\\\n\t\t\t4 & 5 & 6\\\\\n\t\t\t7 & 8 & 9\\\\\n\t\t\\end{bNiceMatrix}^{\\top} &=\n\t\t\\begin{bNiceMatrix}[name=T2]\n\t\t\t1 & 4 & 7\\\\\n\t\t\t2 & 5 & 8\\\\\n\t\t\t3 & 6 & 9\\\\\n\t\t\\end{bNiceMatrix}\\\\[10mm]\n\t\t\\begin{bNiceMatrix}[name=T3]\n\t\t\t0 & 1 & -1\\\\\n\t\t\t2 & -3 & 5\\\\\n\t\t\\end{bNiceMatrix}^{\\top} &=\n\t\t\\begin{bNiceMatrix}[name=T4]\n\t\t\t0 & 2\\\\\n\t\t\t1 & -3\\\\\n\t\t\t-1 & 5\\\\\n\t\t\\end{bNiceMatrix}\\\\[10mm]\n\t\t\\begin{bNiceMatrix}[name=T5]\n\t\t\t1\\\\\n\t\t\t2\\\\\n\t\t\t-1\\\\\n\t\t\t0\\\\\n\t\t\t7\\\\\n\t\t\t-4\\\\\n\t\t\\end{bNiceMatrix}^{\\top} &=\n\t\t\\begin{bNiceMatrix}[name=T6]\n\t\t\t1 & 2 & -1 & 0 & 7 & -4\\\\\n\t\t\\end{bNiceMatrix}\n\t\\end{align*}\n\\begin{tikzpicture}[overlay, remember picture, blend mode=multiply, node distance=15pt]\n\t% ---- T1 ---- %\n\t\\MatHL{(T1-1-1),(T1-2-1),(T1-3-1)}{xred!20}\n\t\\MatHL{(T1-1-2),(T1-2-2),(T1-3-2)}{xorange!20}\n\t\\MatHL{(T1-1-3),(T1-2-3),(T1-3-3)}{xgreen!20}\n\t\\node[below of=T1-3-2] {$3\\times3$};\n\t% ---- T2 ---- %\n\t\\MatHL{(T2-1-1),(T2-1-2),(T2-1-3)}{xred!20}\n\t\\MatHL{(T2-2-1),(T2-2-2),(T2-2-3)}{xorange!20}\n\t\\MatHL{(T2-3-1),(T2-3-2),(T2-3-3)}{xgreen!20}\n\t\\node[below of=T2-3-2] {$3\\times3$};\n\t\n\t% ---- T3 ---- %\n\t\\MatHL{(T3-1-1),(T3-2-1)}{xred!20}\n\t\\MatHL{(T3-1-2),(T3-2-2)}{xorange!20}\n\t\\MatHL{(T3-1-3),(T3-2-3)}{xgreen!20}\n\t\\node[below of=T3-2-2] {$2\\times3$};\n\t% ---- T4 ---- %\n\t\\MatHL{(T4-1-1),(T4-1-2)}{xred!20}\n\t\\MatHL{(T4-2-1),(T4-2-2)}{xorange!20}\n\t\\MatHL{(T4-3-1),(T4-3-2)}{xgreen!20}\n\t\\node[below of=T4-3-1, xshift=10pt] {$3\\times2$};\n\t\n\t% ---- T5 ---- %\n\t\\MatHL{(T5-1-1),(T5-2-1),(T5-3-1),(T5-4-1),(T5-5-1),(T5-6-1)}{xred!20}\n\t\\node[below of=T5-6-1] {$6\\times1$};\n\t% ---- T6 ---- %\n\t\\MatHL{(T6-1-1),(T6-1-2),(T6-1-3),(T6-1-4),(T6-1-5),(T6-1-6)}{xred!20}\n\t\\node[below of=T6-1-3, xshift=10pt] {$1\\times6$};\n\\end{tikzpicture}\n\\end{example}\n\nSince for the main diagonal elements of a matrix the row and column have equal indeces, the transpose operation does not affect their position in the matrix, i.e. $\\Ma{i}{i}\\xrightarrow[] {\\text{transpose}}\\Ma{i}{i}$. This means that $\\tr{A}=\\tr{A^{\\top}}$. Also, diagonal matrices are not affected by a transpose. The transpose of a transposed matrix is the original matrix, i.e. $\\left(A^{\\top}\\right)^{\\top} = A$.\n\nMuch like vectors, a matrix can be scaled by a real number, and two matrices can be added together if their dimensions are identical. The rules for scaling a matrix by a scalar and the addition of two matrices are the same as with vectors, namely everything is dome element wise:\n\\begin{descitemize}\n\t\\item[Scaling] given a matrix\n\t\t\\[\n\t\t\tA = \n\t\t\t\\begin{bNiceMatrix}\n\t\t\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\t\t\\end{bNiceMatrix}\n\t\t\\]\n\t\tand a scalar $\\gamma\\in\\mathbb{R}$, their product is\n\t\t\\begin{equation}\n\t\t\t\\gamma A = \n\t\t\t\\begin{bNiceMatrix}\n\t\t\t\t\\gamma\\cdot\\Ma{1}{1} & \\gamma\\cdot\\Ma{1}{2} & \\cdots & \\gamma\\cdot\\Ma{1}{n}\\\\\n\t\t\t\t\\gamma\\cdot\\Ma{2}{1} & \\gamma\\cdot\\Ma{2}{2} & \\cdots & \\gamma\\cdot\\Ma{2}{n}\\\\\n\t\t\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\t\t\\gamma\\cdot\\Ma{m}{1} & \\gamma\\cdot\\Ma{m}{2} & \\cdots & \\gamma\\cdot\\Ma{m}{n}\n\t\t\t\\end{bNiceMatrix}.\n\t\t\t\\label{eq:matrix_scaling}\n\t\t\\end{equation}\n\n\t\\item[Addition] given two matrices,\n\t\t\\[\n\t\t\tA = \n\t\t\t\\begin{bNiceMatrix}\n\t\t\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\t\t\\end{bNiceMatrix},\\quad\n\t\t\tB = \n\t\t\t\\begin{bNiceMatrix}\n\t\t\t\t\\Mb{1}{1} & \\Mb{1}{2} & \\cdots & \\Mb{1}{n}\\\\\n\t\t\t\t\\Mb{2}{1} & \\Mb{2}{2} & \\cdots & \\Mb{2}{n}\\\\\n\t\t\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\t\t\\Mb{m}{1} & \\Mb{m}{2} & \\cdots & \\Mb{m}{n}\n\t\t\t\\end{bNiceMatrix}, \n\t\t\\]\n\t\ttheir sum is\n\t\t\\begin{equation}\n\t\t\tA+B = \n\t\t\t\\begin{bNiceMatrix}\n\t\t\t\t\\Ma{1}{1}+\\Mb{1}{1} & \\Ma{1}{2}+\\Mb{1}{2} & \\cdots & \\Ma{1}{n}+\\Mb{1}{n}\\\\\n\t\t\t\t\\Ma{2}{1}+\\Mb{2}{1} & \\Ma{2}{2}+\\Mb{2}{2} & \\cdots & \\Ma{2}{n}+\\Mb{2}{n}\\\\\n\t\t\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\t\t\\Ma{m}{1}+\\Mb{m}{1} & \\Ma{m}{2}+\\Mb{m}{2} & \\cdots & \\Ma{m}{n}+\\Mb{m}{n}\n\t\t\t\\end{bNiceMatrix}.\n\t\t\t\\label{eq:}\n\t\t\\end{equation}\n\\end{descitemize}\n\n\\begin{note}{Matrix addition}{}\n\tSince matrix addition is done \\textbf{element wise} it is comutative, i.e. for any two $m\\times n$ matrices $A$ and $B$,\n\t\\[\n\t\tA+B = B+A.\n\t\\]\n\\end{note}\n\n\\subsection{Types of matrices}\nAny matrix $A$ which represents a transformation of the type $\\Rs{n}\\to\\Rs{n}$ (i.e. from a space onto itself) has the same number of rows and columns (i.e. its dimension is $n\\times n$):\n\\begin{equation}\n\tA =\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{n}{1} & \\Ma{n}{2} & \\cdots & \\Ma{n}{n}\n\t\\end{bNiceMatrix}. \n\t\\label{eq:square_matrix}\n\\end{equation}\n\nDue to their shape, such matrices are called \\emph{square matrices}. The elements $\\Ma{1}{1},\\Ma{2}{2},\\Ma{3}{3},\\dots,\\Ma{n}{n}$ of a square matrix jointly form its \\emph{main diagonal} (also: \\emph{principal diagonal}):\n\n\\vspace{1em}\n\\begin{equation}\n\tA =\n\t\\begin{bNiceMatrix}[name=A_diag]\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\Ma{1}{3} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\Ma{2}{3} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\Ma{3}{1} & \\Ma{3}{2} & \\Ma{2}{3} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{n}{1} & \\Ma{n}{2} & \\Ma{n}{3} & \\cdots & \\Ma{n}{n}\n\t\\end{bNiceMatrix}. \n\t\\label{eq:square_matrix_main_diag}\n\\end{equation}\n\\begin{tikzpicture}[overlay, remember picture, blend mode=multiply]\n\t\\foreach \\k in {1,...,3,5}{\n\t\t\\node[fill=xgreen!25, rectangle, minimum width=13pt, minimum height=10pt] at (A_diag-\\k-\\k) {};\n\t}\n\\end{tikzpicture}\n\nThe sum of the main diagonal elements is called the \\emph{trace} of the matrix:\n\\begin{equation}\n\t\\tr \\left( A \\right) = \\sum\\limits_{i=1}^{n}\\Ma{i}{i}.\n\t\\label{eq:trace}\n\\end{equation}\n\n\\emph{Triangular matrices} are matrices in which the elements above or below the main diagonal are all zeros, e.g.\n\n\\begin{center}\n\t\\def\\bperc{25}\n\t\\begin{tabular}{p{-1mm}cp{5mm}p{-1mm}c}\n\t\t$U=$ &\n\t\t$\\begin{bmatrix}\n\t\t\t1 & 6 & 6 & -3 \\\\\n\t\t\t\\textcolor{black!\\bperc}{0} & 2 & 7 & 1 \\\\\n\t\t\t\\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} & 3 & 5 \\\\\n\t\t\t\\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} & -4\n\t\t\\end{bmatrix},$\n\t\t\t & &\n\t\t$L=$ &\n\t\t$\\begin{bmatrix}\n\t\t\t1 & \\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} \\\\\n\t\t\t\\tikzmark{LT1} 2 & 3 & \\textcolor{black!\\bperc}{0} & \\textcolor{black!\\bperc}{0} \\\\ \n\t\t\t5 & 1 & -5 & \\textcolor{black!\\bperc}{0} \\\\\n\t\t\t-4 & 1 & 2\\tikzmark{LT2} & -3\n\t\t\\end{bmatrix}.$\n\t\t\\\\[2.5em]\n\t\t\t & upper triangular & & & lower triangular\n\t\\end{tabular}\n\\end{center}\n\nA somewhat formal way of defining the elements \"above\" the main diagonal is all elements $\\Ma{i}{j}$ for which $ji$ the element $\\Ma{i}{j}$ is \"below\" the main diagonal. Note that the transpose of an upper triangular matrix is a lower triangular matrix and vice-versa.\n\n\\begin{challenge}{Upper/lower triangular matrices}{}\n\tShow that if $A$ is an upper triangular matrix then $A^{\\top}$ is a lower triangular matrix, and if $B$ is a lower triangular matrix then $B^{\\top}$ is an upper triangular matrix.\n\\end{challenge}\n\nA \\emph{diagonal matrix} $A$ is a matrix in which all the non-main diagonal elements, i.e. $\\Ma{i}{j}$ where $\\textcolor{xred}{i}\\neq \\textcolor{xblue}{j}$, equal zero. These matrices can be thought of as scaling matrices: each entry $\\Ma{i}{i}$ tells us how the sapce is scaled in the $i$-th dimension.\n\n\\begin{example}{Diagonal matrices}{}\n\tText.\n\\end{example}\nAs we saw in the cases of $\\Rs{2}$ and $\\Rs{3}$, diagonal matrices are \\emph{scaling matrices}: each entry $a_{ii}$ tells us by how much space is scaled in the $i$-th direction.\n\nA very important family of \\textbf{square} matrices are the \\emph{identity matrices}. These matrices have a unique structure: their main diagonal elements are all $1$, while the rest of the elements (the \\emph{off-diagonal elements}) are all $0$:\n\n\\vspace{1em}\n\\begin{equation}\n\tI_{n} =\n\t\\begin{bNiceMatrix}\n\t\t\\tikzmark{I11} 1 & 0 & 0 & \\cdots & 0\\tikzmark{I1n}\\\\\n\t\t0 & 1 & 0 & \\cdots & 0\\\\\n\t\t0 & 0 & 1 & \\cdots & 0\\\\\n\t\t\\vdots & \\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\tikzmark{In1}0 & 0 & 0 & \\cdots & 1\\tikzmark{Inn}\n\t\\end{bNiceMatrix}\n\t\\label{eq:}\n\\end{equation}\n\\begin{tikzpicture}[overlay, remember picture]\n\t \\draw [xred, thick, decorate, decoration={brace, amplitude=3pt, raise=7pt}] (pic cs:I1n) -- (pic cs:Inn) node[midway, right, xshift=10pt]{$n$ rows};\n\t \\draw [xblue, thick, decorate, decoration={brace, amplitude=3pt, raise=10pt}] (pic cs:I11) -- (pic cs:I1n) node[midway, above, yshift=13pt]{$n$ columns};\n\\end{tikzpicture}\n\nSometimes for clarity large areas of zero-value elements in a matrix are depicted together. In that form, the identity matrix is written as\n\\[\n\tI_{n} =\n\t\\begin{bNiceMatrix}\n\t1 & & \\Block{2-3}<\\huge>{0} \\\\\n\t\t& 1 & & & \\\\\n\t\t& & 1 & & \\\\\n\t\\Block{2-3}<\\huge>{0}\n\t\t& & & \\Ddots & \\\\\n\t\t& & & & 1 \\\\\n\t\\end{bNiceMatrix}.\n\\]\nIn such a depiction, the off-diagonal elements are each written using a single zero. This kind of notation will come in handy in later sections. Yet another way of defining the identity matrix is by using the \\emph{Kronecker delta}, which takes two integers $i,j$ and returns $1$ if they are equal, otherwise it returns $0$:\n\\begin{equation}\n\t\\delta_{ij} =\n\t\\begin{cases}\n\t\t1 & i=j,\\\\\n\t\t0 & i\\neq j.\n\t\\end{cases}\n\t\\label{eq:kronecker_delta}\n\\end{equation}\nUsing the Kronecker delta, each element $a_{ij}$ of the identity matrix $I_{n}$ simply equals $\\delta_{ij}$.\n\nAn identity matrix of dimension $n$ represents the identity transformation in $\\Rs{n}$: each standard basis vector $\\eb{i}$ is left unchanged by the transformation.\n\n\\begin{example}{Identity matrices}{}\n\tThe following are the identity matrices of $\\Rs{2},\\Rs{3},\\dots,\\Rs{6}$, where in each matrix the main diagonal is highlighted:\n\n\t\\centering\n\t\\setlength\\tabcolsep{3pt}\n\t\\begin{tabular}{ccccc}\n\t\t\\IdentityHl{2}{I2}{xred!30} & \\IdentityHl{3}{I3}{xblue!30} & \\IdentityHl{4}{I4}{xgreen!30} & \\IdentityHl{5}{I5}{xpurple!30} & \\IdentityHl{6}{I6}{xorange!30} \\\\\n\t\t$I_{2}$ & $I_{3}$ & $I_{4}$ & $I_{5}$ & $I_{6}$\n\t\\end{tabular}\n\\end{example}\nIn the next section we will see the importance of the identity matrices.\n\nAnother important family of matrices are the \\emph{orthogonal matrices} (also \\emph{orthonormal matrices}): we say that a matrix $Q$ is an orthogonal matrix if all of its columns, when viewed as column vectors, form an orthonormal set. For example, the identity matrices are all orthogonal matrices. Another orthogonal matrix is the matrix\n\\begin{equation}\n\tB = \\frac{1}{\\sqrt{2}}\\begin{bmatrix}1&1\\\\1&-1\\end{bmatrix},\n\t\\label{eq:}\n\\end{equation}\nsince both $\\frac{1}{\\sqrt{2}}\\colvec{1;1}$ and $\\frac{1}{\\sqrt{2}}\\colvec{1;-1}$ are unit vectors, and they are orthogonal to each other (as seen in REF).\n\nA \\emph{symmetric matrix} is a square matrix for which\n\\begin{equation}\n\tA^{\\top} = A.\n\t\\label{eq:symmetric_matrix}\n\\end{equation}\n\"Graphically\", the symmetry of such matrices can be seen in respect to their main diagonal: if we imagine placing a mirror on the main diagonal, each element $\\Ma{i}{j}$ would be \"reflected\" across the mirror, and thus be equal to $\\Ma{j}{i}$ (see example below).\n\n\n\\begin{example}{Symmetric matrix}{}\n\tThe following matrix $S$ is a symmetric $4\\times4$ matrix, in which the elements $a_{ij},a_{ji}$ are higlighted with the same color:\n\n\t\\centering\n\t\\begin{tikzpicture}[node distance=1.6cm]\n\t\t\\node (Seq) {$S=$};\n\t\t\\matrix (S) [matrix of nodes, right of=Seq, left delimiter={[}, right delimiter={]}]{\n\t\t\t1 & 3 & 5 & 7\\\\\n\t\t\t3 & 0 & 1 & 3\\\\\n\t\t\t5 & 1 & 4 & 2\\\\\n\t\t\t7 & 3 & 2 & 6\\\\\n\t\t};\n\t\t\\tikzset{every node/.style={inner sep=0}}\n\t\t\\scoped[on background layer]{\n\t\t\t\\foreach \\k in {1,...,4}\n\t\t\t\t\\node[fill=white, fit=(S-\\k-\\k)(S-\\k-\\k)] {};\n\t\t\t\\node[fill=xred!20, fit=(S-1-2)(S-1-2)] {};\n\t\t\t\\node[fill=xred!20, fit=(S-2-1)(S-2-1)] {};\n\t\t\t\\node[fill=xblue!20, fit=(S-1-3)(S-1-3)] {};\n\t\t\t\\node[fill=xblue!20, fit=(S-3-1)(S-3-1)] {};\n\t\t\t\\node[fill=xgreen!20, fit=(S-1-4)(S-1-4)] {};\n\t\t\t\\node[fill=xgreen!20, fit=(S-4-1)(S-4-1)] {};\n\t\t\t\\node[fill=xpurple!20, fit=(S-2-3)(S-2-3)] {};\n\t\t\t\\node[fill=xpurple!20, fit=(S-3-2)(S-3-2)] {};\n\t\t\t\\node[fill=xorange!20, fit=(S-2-4)(S-2-4)] {};\n\t\t\t\\node[fill=xorange!20, fit=(S-4-2)(S-4-2)] {};\n\t\t\t\\node[fill=xpink!20, fit=(S-3-4)(S-3-4)] {};\n\t\t\t\\node[fill=xpink!20, fit=(S-4-3)(S-4-3)] {};\n\t\t}\n\t\\end{tikzpicture}\n\\end{example}\n\\begin{note}{Transpose of a symmetric matrix}{}\n\tA symmetric matrix is its own transpose, i.e. if $A$ is a symmetric matrix then $A^{\\top}=A$.\n\\end{note}\n\nA rather non-interesting family of matrices are the \\emph{zero matrices}: these are matrices which have only zero-elements, i.e.\n\\begin{equation}\n\t\\bm{0}_{n} =\n\t\\begin{bNiceMatrix}\n\t\t\\tikzmark{z1}0 & 0 & \\cdots & 0\\tikzmark{z2}\\\\\n\t\t0 & 0 & \\cdots & 0\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t0 & 0 & \\cdots & 0\\tikzmark{z3}\n\t\\end{bNiceMatrix}.\n\t\\label{eq:}\n\\end{equation}\n\\begin{tikzpicture}[overlay, remember picture]\n\t \\draw [xred, thick, decorate, decoration={brace, amplitude=3pt, raise=7pt}] (pic cs:z2) -- (pic cs:z3) node[midway, right, xshift=10pt]{$m$ rows};\n\t \\draw [xblue, thick, decorate, decoration={brace, amplitude=3pt, raise=10pt}] (pic cs:z1) -- (pic cs:z2) node[midway, above, yshift=13pt]{$n$ columns};\n\\end{tikzpicture}\nThe zero matrices are called that way since for a given matrix $A$,\n\\begin{align}\n\tA + \\bm{0} &=\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix}\n\t+\n\t\\begin{bNiceMatrix}\n\t\t0 & 0 & \\cdots & 0\\\\\n\t\t0 & 0 & \\cdots & 0\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t0 & 0 & \\cdots & 0\n\t\\end{bNiceMatrix}\\nonumber\\\\\n\t\t\t &=\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1}+0 & \\Ma{1}{2}+0 & \\cdots & \\Ma{1}{n}+0\\\\\n\t\t\\Ma{2}{1}+0 & \\Ma{2}{2}+0 & \\cdots & \\Ma{2}{n}+0\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1}+0 & \\Ma{m}{2}+0 & \\cdots & \\Ma{m}{n}+0\n\t\\end{bNiceMatrix}\\nonumber\\\\\n\t\t\t &=\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix}\n\t= A.\n\\end{align}\nI.e. much like the number zero and the zero vector, the zero matrix is neutral in respect to addition.\n\n\\subsection{The determinant}\nAs mentioned in \\autoref{sec:LS_developing_intuition}, linear transformation scale all volumes by the same amount\\footnote{remember that 2-dimensional volumes are areas.}. This scaling factor is encapsulated in the matrix representing the transformation by a number called the \\emph{determinant} of the matrix. The determinant of a matrix $A$ is written as $|A|$ and sometimes $\\det(A)$.\n\n\\begin{example}{The determinant as a scaling factor}{}\n\tIn the following transformation, represented by the matrix $A=\\begin{bmatrix}\\frac{1}{2}&0\\\\0&1\\end{bmatrix}$, areas are scaled by a factor of $\\frac{1}{2}$ and therefore $|A|=\\frac{1}{2}$ (the number inside each shapes is its area):\n\n\t\\center\n\t\\begin{tikzpicture}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=7cm, height=7cm,\n\t\t\txmin=-5, xmax=5,\n\t\t\tymin=-5, ymax=5,\n\t\t\tminor tick num=1,\n\t\t\tticklabel style={font=\\tiny},\n\t\t]\n\t\t\t\\draw[thick, xred, fill=xred!20] (-4,-4) rectangle (-3,-3) node[shnode] {$1$};\n\t\t\t\\draw[thick, xgreen, fill=xgreen!20] (-4,4) rectangle (-2,1) node[shnode] {$6$};\n\t\t\t\\draw[thick, xpurple, fill=xpurple!20] (4,2) arc (0:360:1.2616) node[black, xshift=-7mm] {$5$};\n\t\t\\end{axis}\n\t\t\\pgftransformcm{1}{0}{0}{1}{\\pgfpoint{7cm}{0}}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=7cm, height=7cm,\n\t\t\txmin=-10, xmax=10,\n\t\t\tymin=-5, ymax=5,\n\t\t\tminor x tick num=2,\n\t\t\tminor y tick num=1,\n\t\t\txtick={-8,-4,...,8},\n\t\t\txticklabels={-4,-2,2,4},\n\t\t\tticklabel style={font=\\tiny},\n\t\t]\n\t\t\\draw[thick, xred, fill=xred!20] (-4,-4) rectangle (-3,-3) node[shnode] {$\\frac{1}{2}$};\n\t\t\\draw[thick, xgreen, fill=xgreen!20] (-4,4) rectangle (-2,1) node[shnode] {$3$};\n\t\t\\draw[thick, xpurple, fill=xpurple!20] (4,2) arc (0:360:0.8921) node[black, xshift=-2.5mm] {$\\frac{5}{2}$};\n\t\t\\end{axis}\n\t\t\\draw[vector] (-1.3cm,3.5cm) -- ++(1cm,0) node[midway, above] {$A$} node[midway, below] {$|A|=\\frac{1}{2}$};\n\t\\end{tikzpicture}\n\\end{example}\n\nSince there is not much sense in discussing volume changes between different spaces (e.g. $\\Rs{5}\\to\\Rs{7}$), only square matrices, which as you recall represent linear transformations from a space onto itself, have determinants. Determinants can take any real number as values, including zero and negative numbers.\n\nWhat does a zero determinant mean? Since in $\\Rs{2}$ determinants tells us the scaling factor of areas by the transformation, if the matrix representing the linear transformation has a zero determinant, it means that somehow all areas are \"squashed\" by the transformation to zero. There are two possible relevant shapes of zero area: a line going through the origin, or the origin itself which is a point. See \\autoref{fig:zero_det_R2} for a visualization.\n\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=6cm, height=6cm,\n\t\t\txmin=-2, xmax=2,\n\t\t\tymin=-2, ymax=2,\n\t\t\txticklabels={,},\n\t\t\tyticklabels={,},\n\t\t]\n\t\t\t\\fill[xpurple, opacity=0.2] (0,0) rectangle (1,1) node[midway, anchor=center, opacity=1] {$S=1$};\n\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[midway, below] {$\\hat{x}$};\n\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[midway, left] {$\\hat{y}$};\n\t\t\\end{axis}\n\t\t\\pgftransformcm{1}{0}{0}{1}{\\pgfpoint{7cm}{0}}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=6cm, height=6cm,\n\t\t\txmin=-2, xmax=2,\n\t\t\tymin=-2, ymax=2,\n\t\t\txticklabels={,},\n\t\t\tyticklabels={,},\n\t\t]\n\t\t\t\\draw[vector, xred] (0,0) -- (2,1) node[midway, above] {$\\hat{x}$};\n\t\t\t\\draw[vector, xblue] (0,0) -- (-1,-0.5) node[midway, below] {$\\hat{y}$};\n\t\t\\end{axis}\n\t\t\\draw[vector] (-2cm,3cm) -- ++(1.6cm,0) node[midway, above] {$|A|=0$};\n\t\\end{tikzpicture}\n\t\\caption{A transformation which \"squashes\" all areas into a line is represented by a matrix $A$ with $|A|=0$. Note how the unit volume defined by $\\cxhat$ and $\\cyhat$ is transformed into a shape of zero area: a line going through the origin. Also note that $\\cxhat$ and $\\cyhat$ are linearly dependent, since they lie on the same line. Cf. \\autoref{fig:det_2x2}.}\n\t\\label{fig:zero_det_R2}\n\\end{figure}\n\nSimilarily, in $\\Rs{3}$ the determinant tells us how volumes are scaled by a linear transformation, and thus a $3\\times3$ matrix with zero determinant means that all the transformation represented by the matrix \"squashes\" all volumes to one of three relevant shapes with zero volume: a plane going through the origin, a line going through the origin, or the origin point itself. See \\autoref{fig:zero_det_R3} for a visualization.\n\nDISCUSSION OF NEGATIVE DETERMINANTS\\ldots\n\nTo calculate the determinant of a matrix, we start with the simplest case: $2\\times2$ matrices. Since all areas are equaly scaled by a linear transformation, we look at the unit sqaure defined by $\\hat{x}$ and $\\hat{y}$ (see \\autoref{fig:det_2x2}). After the application of the transformation represented by the generic matrix $A=\\begin{bmatrix}a&c\\\\b&d\\end{bmatrix}$ (where $a,b,c,d\\in\\mathbb{R}$), these basis vectors are transformed into the vectors \n\\begin{equation}\n\tA\\hat{x}=\\colvec{a;b} \\mkern9mu \\text{and} \\mkern9mu A\\hat{y}=\\colvec{c;d},\n\t\\label{eq:}\n\\end{equation}\nrespectively.\n\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=6cm, height=6cm,\n\t\t\txmin=-1, xmax=3,\n\t\t\tymin=-1, ymax=3,\n\t\t\txticklabels={,},\n\t\t\tyticklabels={,},\n\t\t]\n\t\t\t\\fill[xpurple, opacity=0.2] (0,0) rectangle (1,1);\n\t\t\t\\node[xpurple, anchor=center] at (0.5,0.5) {$S=1$};\n\t\t\t\\draw[vector, xred] (0,0) -- (1,0) node[midway, below] {$\\hat{x}$};\n\t\t\t\\draw[vector, xblue] (0,0) -- (0,1) node[midway, left] {$\\hat{y}$};\n\t\t\t\\draw[vector, xred!50, dashed] (0,1) -- (1,1);\n\t\t\t\\draw[vector, xblue!50, dashed] (1,0) -- (1,1);\n\t\t\\end{axis}\n\t\t\n\t\t\\pgftransformcm{1}{0}{0}{1}{\\pgfpoint{7cm}{0}}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=6cm, height=6cm,\n\t\t\txmin=-1, xmax=3,\n\t\t\tymin=-1, ymax=3,\n\t\t\txticklabels={,},\n\t\t\tyticklabels={,},\n\t\t]\n\t\t\t\\coordinate (Ax) at (0.5,1.5);\n\t\t\t\\coordinate (Ay) at (1.5,0.5);\n\t\t\t\\coordinate (Axy) at (2,2);\n\t\t\t\\fill[xpurple, opacity=0.2] (0,0) -- (Ax) -- (Axy) -- (Ay) -- cycle;\n\t\t\t\\node[xpurple, anchor=center] at (1,1) {$S=|A|$};\n\t\t\t\\draw[vector, xred] (0,0) -- (Ax) node[pos=1.1, xshift=-6pt] {$A\\hat{x}$};\n\t\t\t\\draw[vector, xblue] (0,0) -- (Ay) node[pos=1.1, xshift=5pt, yshift=-3pt] {$A\\hat{y}$};\n\t\t\t\\draw[vector, xred!50, dashed] (Ay) -- (Axy);\n\t\t\t\\draw[vector, xblue!50, dashed] (Ax) -- (Axy);\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\caption{Unit area defined by the vectors $\\hat{x}$ and $\\hat{y}$ before application of a linear transformation represented by the matrix $A$ (left) and the parallelogram defined by the vectors $A\\hat{x}$ and $A\\hat{y}$ after application of the transformation (right).}\n\t\\label{fig:det_2x2}\n\\end{figure}\n\nThe unit square defined by $\\hat{x}$ and $\\hat{y}$ is therefore transformed into the parallelogram defined by $A\\hat{x}$ and $A\\hat{y}$. \\autoref{eq:cross_product_2d_algebraic} tells us that the area of the parallelogram is $S=ad-bc$. Therefore, the determinant - which equals the change in area after application of $A$, is\n\\begin{equation}\n\t|A| = ad-bc\n\t\\label{eq:determinant_2x2}\n\\end{equation}\nas well.\n\n\\begin{example}{Determinants of $\\bm{2\\times2}$ matrices}{}\n\tSome $2\\times2$ matrices and their determinants:\n\n\t\\begin{align*}\n\t\t\\begin{bmatrix} 1&-2\\\\0&3 \\end{bmatrix} &\\longrightarrow 1\\cdot3-(-2)\\cdot0 = 3.\\\\\n\t\t\\begin{bmatrix} 1&5\\\\1&3 \\end{bmatrix} &\\longrightarrow 1\\cdot3-1\\cdot5 = -2.\\\\\n\t\t\\begin{bmatrix} 1&2\\\\1&2 \\end{bmatrix} &\\longrightarrow 1\\cdot2-1\\cdot2 = 0.\\\\\n\t\t\\begin{bmatrix} 1&2\\\\2&4 \\end{bmatrix} &\\longrightarrow 1\\cdot4-2\\cdot2 = 0.\\\\\n\t\t\\begin{bmatrix} 0&7\\\\0&-3 \\end{bmatrix} &\\longrightarrow \\cancel{0\\cdot(-3)}-\\cancel{0\\cdot7} = 0.\\\\\n\t\\end{align*}\n\\end{example}\n\nCalculating the determinant of a $3\\times3$ matrix is based on the calculation of the determinant of a $2\\times2$ matrix. First, we should define an idea called a \\emph{minor} of a matrix. The $ij$-minor of a $3\\times3$ matrix $A$ is the determinant of the $2\\times2$ matrix resulting by the removal of the $i$-th row and $j$-th column of $A$, e.g. let\n\\newcommand{\\Aminor}[1]{\n\t\\begin{bNiceMatrix}[name=#1]\n\t\t2 & -5 & 4\\\\\n\t\t-3 & 0 & 2\\\\\n\t\t3 & 3 & 2\\\\\n\t\\end{bNiceMatrix}\n}\n\\[\n\tA = \\Aminor{A00},\n\\]\nthen \\autoref{tab:minors_of_A} shows all the minors of $A$.\n\n\\begin{table}\n\t\\centering\n\t\\caption{All the minors of the matrix $A$.}\n\t\\label{tab:minors_of_A}\n\t\\begin{tabular}{lcccr}\n\t\t\\toprule\n\t\t$i$ & $j$ & $3\\times3$-matrix & $2\\times2$ determinant & value\\\\\n\t\t\\midrule\n\t\t$1$ & $1$ & $\\Aminor{A11}$ & $\\begin{vmatrix}0&2\\\\3&2\\end{vmatrix}$ & $-6 $\\\\[10mm]\n\t\t$1$ & $2$ & $\\Aminor{A12}$ & $\\begin{vmatrix}-3&2\\\\3&2\\end{vmatrix}$ & $-12$\\\\[10mm]\n\t\t$1$ & $3$ & $\\Aminor{A13}$ & $\\begin{vmatrix}-3&0\\\\3&3\\end{vmatrix}$ & $-9 $\\\\[10mm]\n\t\t$2$ & $1$ & $\\Aminor{A21}$ & $\\begin{vmatrix}-5&4\\\\3&2\\end{vmatrix}$ & $-22$\\\\[10mm]\n\t\t$2$ & $2$ & $\\Aminor{A22}$ & $\\begin{vmatrix}2&4\\\\3&2\\end{vmatrix}$ & $-8 $\\\\[10mm]\n\t\t$2$ & $3$ & $\\Aminor{A23}$ & $\\begin{vmatrix}2&-5\\\\3&3\\end{vmatrix}$ & $ 21$\\\\[10mm]\n\t\t$3$ & $1$ & $\\Aminor{A31}$ & $\\begin{vmatrix}-5&4\\\\0&2\\end{vmatrix}$ & $-10$\\\\[10mm]\n\t\t$3$ & $2$ & $\\Aminor{A32}$ & $\\begin{vmatrix}2&4\\\\-3&2\\end{vmatrix}$ & $ 16$\\\\[10mm]\n\t\t$3$ & $3$ & $\\Aminor{A33}$ & $\\begin{vmatrix}2&-5\\\\-3&0\\end{vmatrix}$ & $-15$\\\\\n\t\t\\bottomrule\n\t\\end{tabular}\n\t\\begin{tikzpicture}[overlay, remember picture]\n\t\t\\MatMinor{A11}{3}{1}{1}\n\t\t\\MatMinor{A12}{3}{1}{2}\n\t\t\\MatMinor{A13}{3}{1}{3}\n\t\t\\MatMinor{A21}{3}{2}{1}\n\t\t\\MatMinor{A22}{3}{2}{2}\n\t\t\\MatMinor{A23}{3}{2}{3}\n\t\t\\MatMinor{A31}{3}{3}{1}\n\t\t\\MatMinor{A32}{3}{3}{2}\n\t\t\\MatMinor{A33}{3}{3}{3}\n\t\\end{tikzpicture}\n\\end{table}\n\nUsing the its minors, the determinant of a $3\\times3$ matrix can be calculated using the following formula:\n\\begin{equation}\n\t|A| = a_{11}m_{11} - a_{12}m_{12} + a_{13}m_{13},\n\t\\label{eq:determinant_3x3}\n\\end{equation}\nwhere $a_{ij}$ and $m_{ij}$ are the elements and minors of the matrix, respectively. For example, using the above matrix $A$, we get that\n\\begin{align*}\n\t|A| &= a_{11}m_{11} - a_{12}m_{12} + a_{13}m_{13}\\\\\n\t\t&= 2\\begin{vmatrix}0&2\\\\3&2\\end{vmatrix} - (-5)\\begin{vmatrix}-3&2\\\\3&2\\end{vmatrix} + 4\\begin{vmatrix}-3&0\\\\3&3\\end{vmatrix}\\\\\n\t\t&= 2\\cdot(-6) - (-5)\\cdot(-12) + 4\\cdot(-9)\\\\\n\t\t&= -12 - 60 - 36 = -108.\n\\end{align*}\n\n\\begin{example}{Determinants of $3\\times3$ matrices}{}\n\t\\ldots\n\\end{example}\n\nThe determinant of a $4\\times4$ matrix follows the same pattern, i.e.\n\\begin{equation}\n\t|A| = a_{11}m_{11} - a_{12}m_{12} + a_{13}m_{13} - a_{14}m_{14},\n\t\\label{eq:}\n\\end{equation}\nwhere again $a_{ij}$ and $m_{ij}$ are, respectively, the elements and minors of a matrix. Much like with the case of a minor of a $3\\times3$ matrix being a determinant of a $2\\times2$ matrix, the minor of a $4\\times4$ matrix is a determinant of a $3\\times3$ matrix, itself calculated using determinants of $2\\times2$ matrices. This pattern continues to higher dimensions, i.e. the calculation of the determinant of a $5\\times5$ matrix uses determinants of $5$ $4\\times4$ matrices, the calculation of the determinant of a $6\\times6$ matrix uses $6$ determinants of $5\\times5$ matrices, and so forth. Therefore, the total number of $2\\times2$ determinants needed for the calculation of the determinant of an $n\\times n$ matrix is\n\\begin{equation}\n\td = n\\times(n-1)\\times(n-2)\\times\\cdots\\times5\\times4\\times3 = \\frac{n!}{2}.\n\t\\label{eq:num_of_2x2_dets_in_n_dim_matrix}\n\\end{equation}\n\nSome properties of determinants:\n\\begin{itemize}\n\t\\item In any case where the columns of a matrix form a linearly dependent set, the determinant is zero. This is due to the loss of dimensionality (i.e. at least one basis vector is mapped to a vector which can be written as a linear combination of the other vectors). One obvious case is where there is one or more columns of zeros in the matrix.\n\t\\item The determinant of the transpose of a matrix is the same as the determinant of the original matrix, i.e. $|A|=|A^{\\top}|$. This is due to the fact that all ideas discussed here can be applied directly to row vectors (as mentioned in the previous sections), and the transpose operation essentially switches between these forms: the columns of the original matrix become the rows in its transposed format. Therefore, the previous property applies to the rows of a matrix as well: e.g. a row of zeros means that the determinant is zero.\n\\end{itemize}\n\n\\subsection{Matrix-vector products}\nAs discussed in the first part of this section, matrices represent linear transformations - in fact, we define a matrix in such a way that its product with a vector gives the result of applying the transformation the matrix represents on the vector (see \\autoref{eq:matrix_vector_product}). Let us now review this idea and elaborate a bit on the process of calculating matrix-vector products.\n\nGiven an $m\\times n$ matrix $A$ and an $n$-dimensional vector $\\vec{v}$, the product $A\\vec{v}$ is an $m$-dimensional vector, in which each element $v_{i}$ is the scalar product between the $i$-th \\textbf{row} of $A$ (interpreted as a vector) and the vector $\\vec{v}$ itself. To illustrate this, we use the following $4\\times3$ matrix $A$ and $3$-dimensional vector $\\vec{v}$:\n\\newcommand{\\Amatv}[1]{\n\t\\begin{bNiceMatrix}[name=#1]\n\t\t1 & 0 & 2\\\\\n\t\t-1 & 3 & -1\\\\\n\t\t2 & 4 & 0\\\\\n\t\t6 & 1 & -3\\\\\n\t\\end{bNiceMatrix}\n}\n\\newcommand{\\Vvec}[1]{\n\t\\begin{bNiceMatrix}[name=#1]\n\t\t2\\\\\n\t\t5\\\\\n\t\t-3\\\\\n\t\\end{bNiceMatrix}\n}\n\\[\n\tA=\\Amatv{A0},\\quad\\vec{v}=\\Vvec{v0}\n\\]\n(note that the number of \\textbf{columns} in $A$ is the same as the number of elements of $\\vec{v}$, namely $3$).\n\nThe resulting vector $\\vec{u}$ is then given by the following formula:\n\\[\n\tu_{i} = \\tikzmark{A}A^{i}\\cdot \\vec{v}.\n\\]\n\\tikz[overlay, remember picture, node distance=15pt]{\n\t\\coordinate (Anode) at ($(pic cs:A)+(5pt,-2pt)$);\n\t\\node[below of=Anode, anchor=center, draw=xgreen, fill=xgreen!20, rounded corners, font=\\small] (Atxt) {$i$-th row of $A$};\n\t\\draw[-stealth, xgreen] (Atxt) -- (Anode);\n}\n\n\\vspace{1em}\nIn the following illustration, each row of $A$ is scalar multiplied with the vector $\\vec{v}$, yielding the respective element of $\\vec{u}$. The respective rows of $A$ and elements of $\\vec{v}$ are color-coded for clarity.\n\n\\[\n\t\\renewcommand{\\arraystretch}{1.5}\n\t\\begin{bNiceMatrix}[name=Av1]\n\t\t1 & 0 & 2\\\\\n\t\t0 & 3 & 1\\\\\n\t\t2 & 4 & 0\\\\\n\t\t6 & 1 & 3\\\\\n\t\\end{bNiceMatrix}\n\t\\quad\\quad\\quad\n\t\\begin{bNiceMatrix}[name=vv1]\n\t\t2\\\\5\\\\0\n\t\\end{bNiceMatrix}\n\t\\quad\\quad\\quad\n\t\\begin{bNiceMatrix}[name=u1]\n\t\t1\\cdot2+\\cancel{0\\cdot5}+\\cancel{2\\cdot0}\\\\\n\t\t\\cancel{0\\cdot2}+3\\cdot5+\\cancel{1\\cdot0}\\\\\n\t\t2\\cdot2+4\\cdot5+\\cancel{\\cancel{0\\cdot0}}\\\\\n\t\t6\\cdot2+1\\cdot5+\\cancel{3\\cdot0}\\\\\n\t\\end{bNiceMatrix}\n\t\\quad\\quad\n\t\\begin{bNiceMatrix}[name=u2]\n\t\t2\\\\15\\\\24\\\\17\n\t\\end{bNiceMatrix}\n\\]\n\\tikz[overlay, remember picture, blend mode=multiply]{\n\t% \\node[mathl={xorange!20}, fit=(vv1-1-1)(vv1-3-1)] {};\n\t\\node[below of=Av1-4-2, yshift=2pt] (Av1-txt) {$A$};\n\t\\node[below of=vv1-3-1, yshift=-6pt] (vv1-txt) {$\\vec{v}$};\n\t\\node[below of=u1-4-1, yshift=2pt] (u1-txt) {$\\vec{u}$};\n\t\\node[below of=u2-4-1, yshift=2pt] (u2-txt) {$\\vec{u}$};\n\t\\foreach \\r in {1,...,4}{\n\t\t\\node[mathl={xcol\\r!25}, fit=(Av1-\\r-1)(Av1-\\r-3)] {};\n\t\t\\node[mathl={xcol\\r!25}, fit=(u1-\\r-1)(u1-\\r-1)] {};\n\t\t\\node[mathl={xcol\\r!25}, fit=(u2-\\r-1)(u2-\\r-1)] {};\n\t\t\\pgfmathsetmacro{\\a}{(\\r-2.5)*8}\n\t\t\\draw[thick, -stealth, xcol\\r] ($(Av1-\\r-3.east)+(7pt,0pt)$) to [out=0, in=180] ($(vv1-2-1.west)-(7pt,\\a pt)$);\n\t\t\\draw[thick, -stealth, xcol\\r] ($(vv1-2-1.east)+(7pt,-\\a pt)$) to [out=0, in=180] ($(u1-\\r-1.west)-(7pt,0)$);\n\t\t\\draw[thick, -stealth, xcol\\r] ($(u1-\\r-1.east)+(7pt,0)$) to ($(u2-\\r-1.west)-(7pt,0)$);\n\t}\n}\n\n\\vspace{2em}\n\\begin{example}{Matrix-vector products}{}\n\tThe following are some examples of matrix-vector products. Note how in each product the number of columns in the matrix is the same as the number of elements of the vector.\n\n\t\\begin{align*}\n\t\t&\\begin{bmatrix}1 & 0 & 2\\\\3 & -1 & 5\\end{bmatrix}\\cdot\\colvec{2;-7;4} = \\colvec{1\\cdot2+\\cancel{0\\cdot(-7)}+2\\cdot4;3\\cdot2-1\\cdot(-7)+5\\cdot4} = \\colvec{10;33}.\\\\[5mm]\n\t\t&\\begin{bmatrix}0 & 4 & -5\\\\4 & 6 & -2\\\\-2 & 2 & 0\\\\\\end{bmatrix} \\cdot \\colvec{0;-3;-2} = \\colvec{\\cancel{\\cancel{0\\cdot0}}+4\\cdot(-3)-5\\cdot(-2);\\cancel{4\\cdot0}+6\\cdot(-3)-2\\cdot(-2);-\\cancel{2\\cdot0}+2\\cdot(-3)+\\cancel{0\\cdot(-2)}} = \\colvec{-2;-14;-6}.\\\\[5mm]\n\t\t&\\begin{bmatrix}-2 & -1\\\\-2 & 1\\\\\\end{bmatrix} \\cdot \\colvec{0;-1} = \\colvec{-\\cancel{2\\cdot0}-1\\cdot(-1);-\\cancel{2\\cdot0}+1\\cdot(-1)} = \\colvec{1;-1}.\\\\[5mm]\n\t\t&\\begin{bmatrix}6 & -1\\\\5 & 0\\\\\\end{bmatrix} \\cdot \\colvec{2;2} = \\colvec{6\\cdot2-1\\cdot2;5\\cdot2+\\cancel{0\\cdot2}} = \\colvec{10;10}.\\\\[5mm]\n\t\t&\\begin{bmatrix}2 & -1 & -2 & -2\\\\2 & 0 & 0 & 5\\\\\\end{bmatrix} \\cdot \\colvec{0;-2;2;4} = \\colvec{\\cancel{2\\cdot0}-1\\cdot(-2)-2\\cdot2-2\\cdot4;\\cancel{2\\cdot0}+\\cancel{0\\cdot(-2)}+\\cancel{0\\cdot2}+5\\cdot4} = \\colvec{-10;20}.\\\\[5mm]\n\t\t&\\begin{bmatrix}3 & 4 & -1 & 1\\\\-2 & 5 & 6 & -2\\\\4 & 5 & -1 & 3\\\\\\end{bmatrix} \\cdot \\colvec{6;3;0;4} = \\colvec{3\\cdot6+4\\cdot3-\\cancel{1\\cdot0}+1\\cdot4;-2\\cdot6+5\\cdot3+\\cancel{6\\cdot0}-2\\cdot4;4\\cdot6+5\\cdot3-\\cancel{1\\cdot0}+3\\cdot4} = \\colvec{34;-5;51}.\n\t\\end{align*}\n\\end{example}\n\n\\subsection{Matrix-matrix products}\nSince the product of a matrix and a vector is itself a vector, one can take the resulting vector and multiply it by another matrix, i.e. given the matrices $A,B$ and a vector $\\vec{v}$, the expression\n\n\\[\n\tB\\cdot \\left( A\\cdot\\vec{v} \\right)\n\\]\nis a vector as well.\n\nOf course, the dimensions of all participating objects must align for the products to be properly defined: if $A$ is an $m\\times n$ matrix, then $\\vec{v}$ must be an $n$-dimensional vector. The result of the product $A\\cdot\\vec{v}$ is then an $m$-dimensional vector which we can call $\\vec{u}$. Thus, for the product $B\\cdot\\vec{u}$ to be properly defined, $B$ must have the same number of columns as $\\vec{u}$ has elements, namely $m$ columns. The number of rows is free, and can be any natural number $k$. Therefore, $B$ is a $k\\times n$ matrix, and the product $B\\cdot\\vec{u}$ is a $k$-dimensional vector.\n\n\\begin{example}{Multiple matrix-vector products}{}\n\tLet\n\t\\[\n\t\tA=\\begin{bmatrix}2 & -1 & 0\\\\5 & 4 & 3\\end{bmatrix},\\quad B=\\begin{bmatrix} 5 & 2\\\\6 & -7\\\\-1 & 0\\end{bmatrix},\\quad \\vec{v}=\\colvec{1;2;5},\n\t\\]\n\tthen\n\t\\[\n\t\t\\vec{u} = A\\cdot\\vec{v} = \\colvec{2\\cdot1-1\\cdot2+\\cancel{0\\cdot5};5\\cdot1+4\\cdot2+3\\cdot5} = \\colvec{0;28}.\n\t\\]\n\tThe product $B\\cdot\\vec{u}$ is defined, since $\\vec{u}$ has the same number of elements as $B$ has columns (namely $2$). Its result is the $3$-dimensional vector\n\t\\[\n\t\t\\vec{w} = B\\cdot\\vec{u} = \\colvec{\\cancel{5\\cdot0}+2\\cdot28;\\cancel{6\\cdot0}-7\\cdot28;-\\cancel{1\\cdot0}+\\cancel{0\\cdot2}8} = \\colvec{56;-196;0}.\n\t\\]\n\\end{example}\n\nMultiple matrix-vector product therefore represent application of multiple linear transformations on an initial vector, in the order the matrix-vector products are performed. For example, consider the vector $\\vec{v}=\\colvec{1;1}$. Rotating $\\vec{v}$ by $\\frac{\\pi}{2}\\ (=\\ang{90})$ counter-clockwise around the origin and then scaling the result by $2$ should yield the vector $\\vec{w}=\\colvec{-2;2}$:\n\\[\n\t\\colvec{1;1} \\xrightarrow[] {\\text{rotation by $\\frac{\\pi}{2}$}} \\colvec{-1;1} \\xrightarrow[] {\\text{scaling by $2$}} \\colvec{-2;2}.\n\\]\n\nUsing the respective matrix representation of each transformation, we get the following:\n\\[\n\t\\begin{bNiceMatrix}[name=mp1] 2 & 0\\\\0 & 2\\end{bNiceMatrix} \\cdot \\left( \\begin{bNiceMatrix}[name=mp2] 0 & 1\\\\-1 & 0 \\end{bNiceMatrix} \\cdot \\begin{bNiceMatrix}[name=mpv1]1\\\\1\\end{bNiceMatrix} \\right) = \\begin{bNiceMatrix}[name=mp3] 2 & 0\\\\0 & 2 \\end{bNiceMatrix} \\cdot \\begin{bNiceMatrix}[name=mpv2] -1\\\\1 \\end{bNiceMatrix} = \\colvec{-2;2}.\n\\]\n\\tikz[overlay, remember picture, blend mode=multiply]{\n\t\\node[mathl={xred!20}, fit=(mp1-1-1)(mp1-2-2)] {};\n\t\\node[mathl={xgreen!20}, fit=(mp2-1-1)(mp2-2-2)] {};\n\t\\node[mathl={xgreen!20}, fit=(mpv1-1-1)(mpv1-2-1)] {};\n\t\\node[mathl={xred!20}, fit=(mp3-1-1)(mp3-2-2)] {};\n\t\\node[mathl={xgreen!20}, fit=(mpv2-1-1)(mpv2-2-1)] {};\n}\n(note that the matrix-vector products are performed from right to left)\n\nMore generally, there could be several products made successionally, i.e.\n\\[\n\tA_{n} \\left( A_{n-1} \\left( A_{n-2} \\cdots \\left( A_{2} \\left( A_{1}\\vec{v} \\right) \\right) \\right) \\right).\n\\]\nMatrix-vector products are most commonly written without the paranthesis nor the dot symbol, i.e. as\n\\[\n\tA_{n}A_{n-1}A_{n-2}\\cdots A_{2}A_{1}\\vec{v},\n\\]\nand the order of multiplication is from left to right, i.e. $A_{1}$ is the first matrix to be multiplied by $\\vec{v}$, then $A_{2}$ is multiplied by the result of the product $A_{1}\\vec{v}$, then $A_{3}$ is multiplied by the result of $A_{2}A_{1}\\vec{v}$ and so on.\n\nAt this point one should wonder whether instead of doing this long chain of products on each individual vector, perhaps the matrices themselves could be multiplied first, yielding a matrix representing the total transformation applied to a vector, as a composition of the separate transformations in the correct order. The answer is of course yes!\\footnote{otherwise this subsection would not be called \"Matrix-matrix products\", after all.}\n\nLet us define the product of two matrices: given the an $m\\times n$ matrix $A$ and an $n\\times k$ matrix $B$, the product $C=AB$ is itself a matrix, having the dimension $m\\times k$, in which every element $c_{ij}$ is the scalar product of the row $A^{i}$ and the column $B_{j}$, i.e.\n\\begin{equation}\n\tc_{ij} = A^{i}\\cdot B_{j} = \\sum_{k=1}^{n}a_{ik}b_{kj} = a_{i1}b_{1j} + a_{i2}b_{2j} + \\dots + a_{in}b_{nj}.\n\t\\label{eq:matrix_matrix_product_elements}\n\\end{equation}\n\n\\autoref{fig:matrix_matrix_product_elements} illustrates this idea graphically.\n\n\\begin{figure}\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\matrix [mat] (left) {\n\t\t\t|[draw, fill=xred!30]|a_{11} & |[draw, fill=xred!30]|a_{12}\\\\\n\t\t\ta_{21} & a_{22}\\\\\n\t\t\t|[draw, fill=xblue!30]|a_{31} & |[draw, fill=xblue!30]|a_{32}\\\\\n\t\t};\n\t\t\\matrix [mat] (top) at (4,3.7) {\n\t\t\t|[draw, fill=xred!30]|b_{11} & b_{12} & b_{13} & |[draw, fill=xblue!30]|b_{14} & b_{15}\\\\\n\t\t\t|[draw, fill=xred!30]|b_{21} & b_{22} & b_{23} & |[draw, fill=xblue!30]|b_{24} & b_{25}\\\\\n\t\t};\n\n\t\t\\matrix [mat, text=white] (center) at (4,0) {\n\t\t\t|[draw, black, fill=xred!30]|c_{11} & 0 & 0 & 0 & 0\\\\\n\t\t\t0 & 0 & 0 & 0 & 0\\\\\n\t\t\t0 & 0 & 0 & |[draw, black, fill=xblue!30]|c_{34} & 0\\\\\n\t\t};\n\n\t\t\\node[left=of left, xshift=7mm] {\\huge$A$};\n\t\t\\node[above=of top, yshift=-4mm] {\\huge$B$};\n\t\t\\node[below=of center, yshift=1cm] {\\huge$C=AB$};\n\n\t\t\\draw[boxarr, xred] (left-1-2) -- (center-1-1);\n\t\t\\draw[boxarr, xblue] (left-3-2) -- (center-3-4);\n\t\t\\draw[boxarr, xred] (top-2-1) -- (center-1-1);\n\t\t\\draw[boxarr, xblue] (top-2-4) -- (center-3-4);\n\n\t\t\\draw[line width=3pt, xred] (left-1-1.north west) rectangle (left-1-2.south east);\n\t\t\\draw[line width=3pt, xblue] (left-3-1.north west) rectangle (left-3-2.south east);\n\t\t\\draw[line width=3pt, xred] (top-1-1.north west) rectangle (top-2-1.south east);\n\t\t\\draw[line width=3pt, xblue] (top-1-4.north west) rectangle (top-2-4.south east);\n\t\\end{tikzpicture}\n\t\\caption{The element $c_{ij}$ of the matrix $C=AB$ is the scalar product of the $i$-th row of $A$ and the $j$-th column of $B$.}\n\t\\label{fig:matrix_matrix_product_elements}\n\\end{figure}\n\nUsing the previous example, instead of calculating the $\\frac{pi}{2}$ rotation of the vector $\\colvec{1;1}$ and then scaling it by $2$, we calculate the product of the two matrices representing these transformations, and then apply them to the vector:\n\\[\n\tC=\\begin{bmatrix} 0 & -1\\\\1 & 0 \\end{bmatrix}\\begin{bmatrix} 2 & 0\\\\0 & 2 \\end{bmatrix} =\n\t\\begin{bmatrix}\n\t\t\\cancel{0\\cdot2}-\\cancel{1\\cdot0} & \\cancel{\\cancel{0\\cdot0}}-1\\cdot2\\\\\n\t\t1\\cdot2+\\cancel{\\cancel{0\\cdot0}} & \\cancel{1\\cdot0}+\\cancel{0\\cdot2}\n\t\t\\end{bmatrix} = \\begin{bmatrix} 0 & -2\\\\2 & 0 \\end{bmatrix}.\n\\]\nWe then apply $C$ to the vector and get the expected result:\n\\[\n\tC\\vec{v} = \\begin{bmatrix} 0 & -2\\\\2 & 0 \\end{bmatrix} \\colvec{1;1} = \\colvec{\\cancel{0\\cdot1}-2\\cdot1;2\\cdot1+\\cancel{0\\cdot1}} = \\colvec{-2;2}.\n\\]\n\n\\begin{example}{Matrix-matrix products}{}\n\tTBW\n\\end{example}\n\nRecall that the order of composition of linear transformations matters: $T_{1}\\circ T_{2} \\neq T_{2}\\circ T_{1}$. Therefore, matrix-matrix products, which represent such compositions, are non-commutative, i.e.\n\\begin{equation}\n\tAB\\neq BA.\n\t\\label{eq:matrix_matrix_product_non_commutative}\n\\end{equation}\n\n\\begin{example}{Non-commutativity of matrix-matrix products}{}\n\t\n\\end{example}\n\nOf course, there are special cases where $AB=BA$, but these are the exception and not the norm. An example is the the rotation and scaling of the vector $\\colvec{1;1}$ we saw above: if we flip the order of application of the two linear transformations we get the same result. This is true for any vector:\n\n\\centering\n\\begin{tikzpicture}[node distance=2cm]\n\t\\node (xy) {$\\colvec{x;y}$};\n\t\\node[right of=xy, xshift=2cm] (res) {$\\colvec{-2y;2x}$};\n\t\\node at ($(xy)!0.5!(res)+(0,1cm)$) (in1) {$\\colvec{-y;x}$};\n\t\\node at ($(xy)!0.5!(res)-(0,1cm)$) (in2) {$\\colvec{2x;2y}$};\n\t\\draw[-stealth, thick] (xy) -- (in1) node[midway, above, rotate=30] {rotate};\n\t\\draw[-stealth, thick] (xy) -- (in2) node[midway, below, rotate=-30] {scale};\n\t\\draw[-stealth, thick] (in1) -- (res) node[midway, above, rotate=-30] {scale};\n\t\\draw[-stealth, thick] (in2) -- (res) node[midway, below, rotate=30] {rotate};\n\\end{tikzpicture}\n\\flushleft\n\nWe can see that fact by multiplying the two matrices directly, in both directions:\n\\begin{align*}\n\t\\begin{bmatrix}0&-1\\\\1&0\\end{bmatrix}\\begin{bmatrix}2&0\\\\0&2\\end{bmatrix} &= \\begin{bmatrix}\\cancel{0\\cdot2}-\\cancel{1\\cdot0} & \\cancel{\\cancel{0\\cdot0}}-1\\cdot2 \\\\1\\cdot2+\\cancel{\\cancel{0\\cdot0}}&\\cancel{1\\cdot0}+\\cancel{0\\cdot2}\\end{bmatrix} = \\begin{bmatrix}0&-2\\\\2&0\\end{bmatrix},\\\\\n\t\\begin{bmatrix}2&0\\\\0&2\\end{bmatrix}\\begin{bmatrix}0&-1\\\\1&0\\end{bmatrix} &= \\begin{bmatrix}\\cancel{2\\cdot0}+\\cancel{0\\cdot1}&2\\cdot(-1)+\\cancel{\\cancel{0\\cdot0}}\\\\1\\cdot2+\\cancel{\\cancel{0\\cdot0}}&\\cancel{1\\cdot0}+\\cancel{0\\cdot2}\\end{bmatrix} = \\begin{bmatrix}0&-2\\\\2&0\\end{bmatrix}.\n\\end{align*}\n\nLater in this chapter we will analyze the conditions for such commutativity to occur.\n\nThe determinant of a matrix-matrix product $AB$ equals the product of the determinants of the separate matrices, i.e.\n\\begin{equation}\n\t|AB| = |A|\\times|B|.\n\t\\label{eq:determinant_AB}\n\\end{equation}\nThe reason is that the change in volume after application of two consecutive transformations is the product of the change in volume for each separate transformation. This also mean that $|AB|=|BA|$. The trace of a matrix-matrix product behaves the same as well:\n\\begin{equation}\n\t\\tr\\left(AB\\right) = \\tr\\left(BA\\right).\n\t\\label{eq:}\n\\end{equation}\n\n\\begin{proof}{Trace of a matrix-matrix product}{}\n\tProve the above behaviour of the trance operator.\n\\end{proof}\n\nOn the other hand, the traspose operator doesn't behave so \"nicely\":\n\\begin{equation}\n\t\\left(AB\\right)^{\\top} = B^{\\top}A^{\\top}.\n\t\\label{eq:}\n\\end{equation}\n\n\\subsection{Inverse matrices}\nSome linear transformations are invertible. For example, given a transformation which rotates any vector in $\\Rs{2}$ by $\\theta$ \\textbf{counter-clockwise} around the origin, its inverse transformation is one that rotates any vector in $\\Rs{2}$ by $\\theta$ \\textbf{clockwise} around the origin (or equivalently by $-\\theta$ counter-clockwise). \\autoref{fig:trans_and_inverses} illustrates such transformation.\n\n\\begin{figure}[h]\n\t\\centering\n\t\\begin{tikzpicture}[node distance=1pt]\n\t\t\\pgfmathsetmacro{\\tha}{15}\n\t\t\\pgfmathsetmacro{\\thb}{80}\n\t\t\\pgfmathsetmacro{\\thas}{\\tha+3}\n\t\t\\pgfmathsetmacro{\\thbs}{\\thb-3}\n\t\t\\pgfmathsetmacro{\\R}{2.5}\n\t\t\\begin{axis}[\n\t\t\tvector plane,\n\t\t\twidth=10cm, height=10cm,\n\t\t\txmin=-0.5, xmax=3,\n\t\t\tymin=-0.5, ymax=3,\n\t\t\txticklabels={,},\n\t\t\tyticklabels={,},\n\t\t]\n\t\t\t\\coordinate (v) at ({\\R*cos(\\tha)},{\\R*sin(\\tha)});\n\t\t\t\\coordinate (u) at ({\\R*cos(\\thb)},{\\R*sin(\\thb)});\n\t\t\t\\draw[vector, xred] (0,0) -- (v) node[pos=1.05] {$\\vec{u}$};\n\t\t\t\\draw[vector, xblue] (0,0) -- (u) node[pos=1.05] {$\\vec{v}$};\n\t\t\t\\draw[vector, xpurple] ({0.4*\\R*cos(\\thas)},{0.4*\\R*sin(\\thas)}) arc (\\thas:\\thbs:{0.4*\\R});\n\t\t\t\\draw[vector, xpurple] ({0.65*\\R*cos(\\thbs)},{0.65*\\R*sin(\\thbs)}) arc (\\thbs:\\thas:{0.65*\\R});\n\t\t\t\\node[draw=xpurple, thick, fill=xpurple!20, rounded corners, text=xpurple] at (0.75,0.75) {$T$};\n\t\t\t\\node[draw=xpurple, thick, fill=xpurple!20, rounded corners, text=xpurple] at (1.2,1.2) {$T^{-1}$};\n\t\t\\end{axis}\n\t\\end{tikzpicture}\n\t\\caption{The transformation $T$ rotates a vector $\\vu$ by $\\ath$ counter-clockwise, turning it into the vector $\\vv$. Its inverse, $T^{-1}$, turns the vector $\\vv$ back into $\\vu$.}\n\t\\label{fig:trans_and_inverses}\n\\end{figure}\n\nRecall that a transformations (function) is only invertible if and only if it is bijective (\\autoref{sec:relations_and_functions}). Specifically to our case, a non-bijective linear transformation is a transformation $T:\\Rs{m}\\to\\Rs{n}$ for which some two vectors $\\vec{u},\\vec{v}\\in\\Rs{m}$ are mapped to the same vector $\\vec{w}\\in\\Rs{n}$.\n\n\\begin{example}{Two vectors mapped to the same vector}{}\n\tLet $T$ be a linear transformation represented by the matrix\n\t\\[\n\t\tA=\n\t\t\\begin{bmatrix}\n\t\t\t1 & 0 & 2\\\\\n\t\t\t0 & 1 & 0\\\\\n\t\t\t0 & 0 & 0\\\\\n\t\t\\end{bmatrix}.\n\t\\]\n\t\n\tThe two vectors $\\vec{u}=\\colvec{2;0;0}$ and $\\vec{v}=\\colvec{0;0;1}$ are mapped by $T$ to the same vector:\n\t\\begin{align*}\n\t\tA\\vec{u} &= \\colvec{1\\cdot2+\\cancel{\\cancel{0\\cdot0}}+\\cancel{2\\cdot0};\\cancel{0\\cdot2}+\\cancel{1\\cdot0}+\\cancel{\\cancel{0\\cdot0}};\\cancel{0\\cdot2}+\\cancel{\\cancel{0\\cdot0}}+\\cancel{\\cancel{0\\cdot0}}} = \\colvec{2;0;0}.\\\\\n\t\tA\\vec{v} &= \\colvec{\\cancel{1\\cdot0}+\\cancel{0\\cdot0}+2\\cdot1;\\cancel{0\\cdot0}+\\cancel{1\\cdot0}+\\cancel{0\\cdot1};\\cancel{0\\cdot0}+\\cancel{0\\cdot0}+\\cancel{0\\cdot2}} = \\colvec{2;0;0}.\\\\\n\t\\end{align*}\n\\end{example}\n\nIn fact, when a linear transformation maps two vectors in its domain to a single vector in is image - it actually maps \\textbf{infinitely many} vectors to that point: let $T$ be a linear transformation and $\\vec{u},\\vec{v}$ two vectors in its domain that are mapped to the same output $\\vec{w}$, i.e.\n\\[\n\tT \\left( \\vec{u} \\right) = T \\left( \\vec{v} \\right) = \\vec{w}.\n\\]\n\nDue to the properties of linear transformations, on one side we get\n\\begin{align}\n\tT \\left( \\alpha\\vec{v}+\\beta\\vec{u} \\right) &= T \\left( \\alpha\\vec{u} \\right) + T \\left( \\beta\\vec{v} \\right)\\\\ \n\t\t\t\t\t\t\t\t\t\t\t\t&= \\alpha T \\left( \\vec{u} \\right) + \\beta T\\left(\\vec{w}\\right)\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t&= \\alpha\\vec{w} + \\beta\\vec{w}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t&= (\\alpha+\\beta)\\vec{w}.\n\\end{align}\n(for any $\\alpha\\in\\mathbb{R}$)\n\nThus, for example, the linear combination $2\\vec{u}+6\\vec{v}$ will be mapped to the same output as $6\\vec{u}+2\\vec{v},\\ 3\\vec{u}+9\\vec{v},\\ 0.5\\vec{u}+11.5\\vec{v}$, etc. - the linear combination using any two coefficients $\\alpha,\\beta$ which add up to $12$ would be mapped to $12\\vec{w}$. This is of course true for any real number, and so for each scale of $\\vec{w}$ there are infinitely many linear combinations that are mapped to it.\n\nIn fact, the only way in which a linear transformation can be non-bijective is by \"loosing\" a dimension, i.e. when it maps $\\Rs{3}$ to a single plane/line/point. As we saw earlier, these kind of transformations are represented by matrices for which the determinant is zero, i.e.\n\\begin{equation}\n\t|A|=0 \\Leftrightarrow \\nexists A^{-1}.\n\t\\label{eq:determinant_zero_no_inverse}\n\\end{equation}\nwhich in words mean that if (and only if!) the determinant of a matrix is zero then it has no iverse, and vice-versa (the symbol $\\nexists$ means \"does not exist\"). On the other hand, if the determinant isn't zero, then the inverse must exist.\n\nThe product of a matrix and its inverse is the respective identity matrix, since the composition of the respective linear transformations represented by the matrices is the identity transformation. In mathematic terms:\n\\begin{equation}\n\tAA^{-1} = A^{-1}A = I.\n\t\\label{eq:matrix_inverse_identity}\n\\end{equation}\n\n\\begin{example}{Inverse matrices}{}\n\tTBW: give a $3\\times3$ matrix, show that its determinant is non-zero, present its inverse and demonstrate it on a specific vector.\n\\end{example}\n\nMatrices with zero determinant are also known as a \\emph{singular} or \\emph{degenerate} matrix. For obvious reason, we will not use the latter term in this book\\footnote{nor should you use it in general, in my opinion.}.\n\nWhile the identity matrix is its own inverse (since $I\\cdot I=I$), it is not the only matrix which shows such behaviour. For example, consider the matrix\n\\[\n\tA =\n\t\\begin{bmatrix}\n\t\t-1 & 0 & 0\\\\\n\t\t 0 & 1 & 0\\\\\n\t\t 0 & 0 & 1\\\\\n\t\\end{bmatrix}.\n\\]\nGeometrically, $A$ takes a vector in $\\Rs{3}$ and flips its $x$-component. In other words it mirrors any vector across the $yz$-plane (see \\autoref{fig:mirror_yz}). If we take a vector $\\vec{u}=\\colvec{x;y;z}$ and multiply it by $A$ we get the vector $\\vec{v}=\\colvec{-x;y;z}$ (tip: calculate the product $A\\vec{v}$ directly for practice). If we take $\\vec{v}$ and multiply it by $A$, we get the vector $\\colvec{x;y;z}$ - i.e. we retrieved back $\\vec{u}$. Since this is true for any vector in $\\Rs{3}$, $A$ is its own inverse. We can check this directly by calculating the product of $A$ with itself:\n\\begin{align*}\n\tA\\cdot A &=\n\t\\begin{bmatrix}\n\t\t-1 & 0 & 0\\\\\n\t\t 0 & 1 & 0\\\\\n\t\t 0 & 0 & 1\\\\\n\t\\end{bmatrix}\n\t\\begin{bmatrix}\n\t\t-1 & 0 & 0\\\\\n\t\t 0 & 1 & 0\\\\\n\t\t 0 & 0 & 1\\\\\n\t\\end{bmatrix}\\\\\n\t\t\t &=\n\t\\begin{bmatrix}\n\t\t-1\\cdot(-1) + \\cancel{\\cancel{0\\cdot0}}+\\cancel{\\cancel{0\\cdot0}} & -\\cancel{1\\cdot0}+\\cancel{0\\cdot1}+\\cancel{\\cancel{0\\cdot0}} & -\\cancel{1\\cdot0}+\\cancel{\\cancel{0\\cdot0}}+\\cancel{0\\cdot1}\\\\\n\t\t \\cancel{0\\cdot(-1)} + \\cancel{\\cancel{0\\cdot0}}+\\cancel{\\cancel{0\\cdot0}} & \\cancel{0\\cdot1}+1\\cdot1+\\cancel{\\cancel{0\\cdot0}} & \\cancel{\\cancel{0\\cdot0}}+\\cancel{0\\cdot1}+\\cancel{\\cancel{0\\cdot0}}\\\\\n\t\t \\cancel{0\\cdot(-1)} + \\cancel{\\cancel{0\\cdot0}}+\\cancel{0\\cdot1} & \\cancel{\\cancel{0\\cdot0}}+\\cancel{0\\cdot1}+\\cancel{\\cancel{0\\cdot0}} & \\cancel{\\cancel{0\\cdot0}}+\\cancel{\\cancel{0\\cdot0}}+1\\cdot1\\\\\n\t\\end{bmatrix}\\\\\n\t\t\t &=\n\t\\begin{bmatrix}\n\t\t1 & 0 & 0\\\\\n\t\t0 & 1 & 0\\\\\n\t\t0 & 0 & 1\\\\\n\t\\end{bmatrix}\\\\\n\t\t\t &= I_{3}.\n\\end{align*}\n\nA matrix which is its own inverse is known as an \\emph{involutory matrix}. Such matrices must be square (challange to the reader: why is that true?).\n\nHow do we calculate the inverse of a matrix? In general, non-square matrices don't have so-called \"complete\" inverses, so we focus on calculating the inverses of square matrices only. The general formula for an inverse matrix $A^{-1}$ is\n\\begin{equation}\n\tA^{-1} = \\frac{1}{|A|}\\adj(A),\n\t\\label{eq:inverse_matrix_calc}\n\\end{equation}\nwhere $\\adj(A)$ is the \\emph{adjugate} of the matrix $A$. The adjugate of a matrix is calculated using its minors, as follows: let \\[\n\tA=\n\t\\begin{bNiceMatrix}\n\t\t\\Ma{1}{1} & \\Ma{1}{2} & \\cdots & \\Ma{1}{n}\\\\\n\t\t\\Ma{2}{1} & \\Ma{2}{2} & \\cdots & \\Ma{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\Ma{m}{1} & \\Ma{m}{2} & \\cdots & \\Ma{m}{n}\n\t\\end{bNiceMatrix},\n\\]\nthen its adjugate is the matrix\n\\[\n\t\\adj(A)=\n\t\\begin{bNiceMatrix}\n\t\t+\\Mm{1}{1} & -\\Mm{1}{2} & \\cdots & \\pm\\Mm{1}{n}\\\\\n\t\t-\\Mm{2}{1} & +\\Mm{2}{2} & \\cdots & \\mp\\Mm{2}{n}\\\\\n\t\t\\vdots & \\vdots & \\Ddots & \\vdots\\\\\n\t\t\\pm\\Mm{m}{1} & \\mp\\Mm{m}{2} & \\cdots & \\pm\\Mm{m}{n}\n\t\\end{bNiceMatrix}^{\\top}\n\\]\n(where $\\Mm{i}{j}$ is the $\\textcolor{xred}{i}\\textcolor{xblue}{j}$-minor of $A$).\n\n\\begin{example}{Adjugate of a matrix}{}\n\tLet\n\t\\[\n\t\tC=\n\t\t\\begin{bmatrix}\n\t\t\t1 & 7 & -3\\\\\n\t\t\t2 & 5 & 0\\\\\n\t\t\t0 & 1 & 1\\\\\n\t\t\\end{bmatrix},\n\t\\]\n\tthen\n\t\\begin{align*}\n\t\t\\adj(C)&=\n\t\t\\begin{bmatrix}\n\t\t\t+\\Mm{1}{1} & -\\Mm{1}{2} & +\\Mm{1}{3}\\\\\n\t\t\t-\\Mm{2}{1} & +\\Mm{2}{2} & -\\Mm{2}{3}\\\\\n\t\t\t+\\Mm{3}{1} & -\\Mm{3}{2} & +\\Mm{3}{3}\\\\\n\t\t\\end{bmatrix}^{\\top}\\\\\n\t\t\t &=\n\t\t\t \\begin{bmatrix}\n\t\t\t\t +\\begin{vmatrix}5&0\\\\1&1\\end{vmatrix} & -\\begin{vmatrix}2&0\\\\0&1\\end{vmatrix} & +\\begin{vmatrix}2&5\\\\0&1\\end{vmatrix}\\\\\n\t\t\t\t -\\begin{vmatrix}7&-3\\\\1&1\\end{vmatrix} & +\\begin{vmatrix}1&-3\\\\0&1\\end{vmatrix} & -\\begin{vmatrix}1&7\\\\0&1\\end{vmatrix}\\\\\n\t\t\t\t +\\begin{vmatrix}7&-3\\\\5&0\\end{vmatrix} & -\\begin{vmatrix}1&-3\\\\2&0\\end{vmatrix} & +\\begin{vmatrix}1&7\\\\2&5\\end{vmatrix}\\\\\n\t\t\t \\end{bmatrix}^{\\top}\\\\\n\t\t\t &=\n\t\t\t \\begin{bmatrix}\n\t\t\t\t 5\\cdot1-\\cancel{1\\cdot0} & -2\\cdot1+\\cancel{\\cancel{0\\cdot0}} & 2\\cdot1-\\cancel{0\\cdot5}\\\\\n\t\t\t\t -(7\\cdot1+1\\cdot3) & 1\\cdot1+\\cancel{3\\cdot0} & -(1\\cdot1-\\cancel{7\\cdot0})\\\\\n\t\t\t\t \\cancel{7\\cdot0}+3\\cdot5 & -(\\cancel{1\\cdot0}+3\\cdot2) & 1\\cdot5-2\\cdot7\\\\\n\t\t\t \\end{bmatrix}^{\\top}\\\\\n\t\t\t &=\n\t\t\t \\begin{bmatrix}\n\t\t\t\t 5 & -2 & 2\\\\\n\t\t\t\t -10 & 1 & -1\\\\\n\t\t\t\t 15 & -6 & -9\\\\\n\t\t\t \\end{bmatrix}^{\\top}\\\\ \n\t\t\t &=\n\t\t\t \\begin{bmatrix}\n\t\t\t\t 5 & -10 & 15\\\\\n\t\t\t\t -2 & 1 & -6\\\\\n\t\t\t\t 2 & -1 & -9\n\t\t\t \\end{bmatrix}.\n\t\\end{align*}\n\\end{example}\n\nWe can use the above example to calculate the inverse of the matrix $C$.\n\n\\begin{example}{Inverse of a matrix}{}\n\tThe determinant of $C$ is\n\t\\[\n\t\t|C| = \\Mm{1}{1} -7\\Mm{1}{2} -3\\Mm{1}{3} = 5-14-6 = -15.\n\t\\]\n\tTherefore the inverse of $C$ is\n\t\\begin{align*}\n\t\tC^{-1} &= \\frac{1}{|C|}\\adj(C)\\\\\n\t\t\t &= -\\frac{1}{15}\n\t\t\t \\begin{bmatrix}\n\t\t\t\t 5 & -10 & 15\\\\\n\t\t\t\t -2 & 1 & -6\\\\\n\t\t\t\t 2 & -1 & -9\n\t\t\t \\end{bmatrix}\\\\\n\t\t\t &=\n\t\t\t \\begin{bmatrix}\n\t\t\t\t -\\frac{1}{3} & -\\frac{2}{3} & -1\\\\\n\t\t\t\t \\frac{2}{15} & -\\frac{1}{15} & \\frac{6}{15}\\\\\n\t\t\t\t -\\frac{2}{15} & \\frac{1}{15} & \\frac{3}{5}\\\\\n\t\t\t \\end{bmatrix}.\n\t\\end{align*}\n\\end{example}\n\nIn the case of $2\\times2$ matrices, the adjugate has a rather simple formula:\n\\begin{equation}\n\t\\adj\\left( \\begin{bmatrix}a&b\\\\c&d\\end{bmatrix} \\right) = \\begin{bmatrix} d&-b\\\\-c&a \\end{bmatrix}.\n\t\\label{eq:adjugate_2x2}\n\\end{equation}\n\n\\begin{note}{Minors of $\\bm{2\\times2}$ matrices}{}\n\tThe minors of a $2\\times2$ matrix $A=\\begin{bmatrix}a&b\\\\c&d\\end{bmatrix}$ are simply\n\t\\begin{align*}\n\t\t\\Mm{1}{1} &= d,\\ \\Mm{1}{2} = c,\\\\\n\t\t\\Mm{2}{1} &= b,\\ \\Mm{2}{2} = a.\n\t\\end{align*}\n\\end{note}\n\nTherefore, the inverse of a $2\\times2$ matrix $A=\\begin{bmatrix}a&b\\\\c&d\\end{bmatrix}$ is\n\\begin{equation}\n\tA^{-1} = \\frac{1}{|A|}\\begin{bmatrix}d&-b\\\\-c&a\\end{bmatrix} = \\frac{1}{ad-cb}\\begin{bmatrix}d&-b\\\\-c&a\\end{bmatrix}.\n\t\\label{eq:inverse_2x2}\n\\end{equation}\n\nWe can check that \\autoref{eq:inverse_2x2} is correct by directly calculating the products $AA^{-1}$ and $A^{-1}A$:\n\\begin{align*}\n\tAA^{-1} &= \\frac{1}{|A|}\\begin{bmatrix}a&b\\\\c&d\\end{bmatrix}\\begin{bmatrix}d&-b\\\\-c&a\\end{bmatrix}\\\\\n\t\t\t&= \\frac{1}{ad-cb}\\begin{bmatrix} ad-bc & \\cancel{-ab+ba} \\\\ \\cancel{cd-dc} & -cb+da \\end{bmatrix}\\\\\n\t\t\t&= \\begin{bmatrix}\\frac{ad-bc}{ad-cb} & 0 \\\\ 0 & \\frac{da-cb}{ad-bc}\\end{bmatrix}\\\\\n\t\t\t&= \\begin{bmatrix} 1&0 \\\\ 0&1 \\end{bmatrix}\\\\\n\t\t\t&= I_{2}.\\\\\n\t\t\t\\\\\n\tA^{-1}A &= \\frac{1}{|A|}\\begin{bmatrix}d&-b\\\\-c&a\\end{bmatrix}\\begin{bmatrix}a&b\\\\c&d\\end{bmatrix}\\\\\n\t\t\t&= \\frac{1}{ad-cb}\\begin{bmatrix} da-bc & \\cancel{db-bd} \\\\ \\cancel{-ca+ac} & -cb+ad \\end{bmatrix}\\\\\n\t\t\t&= \\begin{bmatrix} \\frac{da-bc}{ad-cb} & 0 \\\\ 0 & \\frac{ad-cb}{ad-cb} \\end{bmatrix}\\\\\n\t\t\t&= \\begin{bmatrix} 1&0 \\\\ 0&1 \\end{bmatrix}\\\\\n\t\t\t&= I_{2}.\n\\end{align*}\n\n\\begin{example}{Inverting a $\\bm{2\\times2}$ matrix}{}\n\tThe inverse of the matrix\n\t\\[\n\t\tA = \\begin{bmatrix}1&-3 \\\\ 2&0\\end{bmatrix}\n\t\\]\n\tis\n\t\\begin{align*}\n\t\tA^{-1} &= \\frac{1}{|A|}\\begin{bmatrix}0&3 \\\\ -2&1\\end{bmatrix}\\\\\n\t\t\t &= \\frac{1}{1\\cdot0-(-3)\\cdot2} \\begin{bmatrix}0&3 \\\\ -2&1\\end{bmatrix}\\\\\n\t\t\t &= \\frac{1}{6}\\begin{bmatrix}0&3 \\\\ -2&1\\end{bmatrix}.\n\t\\end{align*}\n\\end{example}\n\n\\begin{example}{Inverse of the $2$-dimensional rotation matrix}{}\n\tWe can use \\autoref{eq:inverse_2x2} to calculate the inverse of the $2$-dimensional rotation matrix\n\t\\[\n\t\tR \\left( \\theta \\right) = \\begin{bmatrix} \\cos(\\theta) & -\\sin(\\theta) \\\\ \\sin(\\theta) & \\cos(\\theta) \\end{bmatrix}.\n\t\\]\n\tSince the rotation matrix rotates all vector by $\\theta$ counter-clockwise around the origin, we expect its inverse to rotate all vectors by $-\\theta$ counter-clockwise around the origin. Let's show that this is indeed the case: we first calculate the determinant of $R$:\n\t\\[\n\t\t|R| = \\cos(\\theta)\\cdot\\cos(\\theta) + \\sin(\\theta)\\sin(\\theta) = \\cos(\\theta)^{2}+\\sin(\\theta)^{2} = 1.\n\t\\]\n\tThis result makes sense - rotation does not change areas. We can now use $|R|$ to calculate $R^{-1}$:\n\t\\begin{align*}\n\t\tR^{-1} \\left( \\theta \\right) &= \\frac{1}{|R|}\\begin{bmatrix} \\cos(\\theta) & \\sin(\\theta) \\\\ -\\sin(\\theta) & \\cos(\\theta) \\end{bmatrix}\\\\\n\t\t\t\t\t\t\t\t\t &= \\begin{bmatrix} \\cos(\\theta) & \\sin(\\theta) \\\\ -\\sin(\\theta) & \\cos(\\theta) \\end{bmatrix}. \n\t\\end{align*}\n\tSince $\\cos(-\\theta)=\\cos(\\theta)$ and $\\sin(-\\theta)=-\\sin(\\theta)$, the above matrix is exactly a rotation by $-\\theta$ counter-clockwise around the origin, as we expected.\n\\end{example}\n\nWe can use the rotation matrix and its inverse to calculate the general $2\\times2$ reflection matrix around a line going through the origin (\\autoref{eq:reflect_general_2x2}), represented by its angel $\\theta$. We do this by taking the following steps (see \\autoref{fig:building_reflect_2x2} for a graphical illustration):\n\\begin{enumerate}\n\t\\item Rotate space by $-\\theta$ such that the reflection line aligns with the horizontal axis.\n\t\\item Reflect space across the horizontal line.\n\t\\item Rotate space by $\\theta$ to bring back space to its original orientation.\n\\end{enumerate}\n\nThe order of application of the above transformations is 1-2-3. Therefore, in matrix form we write them from \\textbf{left to right}, i.e. $\\bm{3}\\cdot\\bm{2}\\cdot\\bm{1}$:\n\n\\vspace{1em}\n\\centering\n\\tikz[node distance=2.75cm]{\n\t\\node (RefD) {$\\Refl(\\theta)$};\n\t\\node[right of=RefD, xshift=-2cm] (eq1) {$=$};\n\t\\node[fill=xgreen!20, right of=eq1] (rot2) {$\\begin{bmatrix} \\cos(\\theta)&-\\sin(\\theta) \\\\ \\sin(\\theta)&\\cos(\\theta) \\end{bmatrix}$};\n\t\\node[fill=xblue!20, right of=rot2] (ref) {$\\begin{bmatrix} 1&0 \\\\ 0&-1 \\end{bmatrix}$};\n\t\\node[fill=xred!20, right of=ref] (rot1) {$\\begin{bmatrix} \\cos(\\theta)&\\sin(\\theta) \\\\ -\\sin(\\theta)&\\cos(\\theta) \\end{bmatrix}$};\n\t\n\t\\node at ($(rot2.east)!0.5!(ref.west)$) {$\\cdot$};\n\t\\node at ($(ref.east)!0.5!(rot1.west)$) {$\\cdot$};\n\n\t\\tikzset{node distance=1.5cm}\n\t\\node[fill=xgreen!20, above of=rot2] (rot2txt) {3. rotate back};\n\t\\node[fill=xblue!20, above of=ref] (reftxt) {2. flip vertically};\n\t\\node[fill=xred!20, above of=rot1] (rot1txt) {1. rotate};\n\n\t\\draw[vector, xgreen!20] (rot2txt) -- (rot2);\n\t\\draw[vector, xblue!20] (reftxt) -- (ref);\n\t\\draw[vector, xred!20] (rot1txt) -- (rot1);\n\n\t\\tikzset{node distance=2.75cm}\n\t\\node[below of=eq1, yshift=1cm] (eq2) {$=$};\n\t\\node[right of=eq2, xshift=3mm] {$\\begin{bmatrix} \\cos \\left( 2\\theta \\right) & \\sin \\left( 2\\theta \\right) \\\\ -\\sin \\left( 2\\theta \\right) & \\cos \\left( 2\\theta \\right) \\end{bmatrix}.$};\n}\n\\flushleft\n\n\\renewcommand\\thesubfigure{\\arabic{subfigure}}\n\\setcounter{subfigure}{-1} % <-- why doesn't this work? :(\n\\begin{figure}[]\n\t\\centering\n\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\tvector plane,\n\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\txlabel={},\n\t\t\t\tylabel={},\n\t\t\t\txticklabels={,},\n\t\t\t\tyticklabels={,},\n\t\t\t\taxis line style={draw=none},\n\t\t\t\ttick style={draw=none},\n\t\t\t\tgrid=none,\n\t\t\t]\n\t\t\t\\node at (0,0) {\\includesvg[scale=0.75]{figures/linear_algebra/tapir_transform2}};\n\t\t\t\\addplot[thick, dashed] {0.5*\\x};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{Original space.}\n\t\\end{subfigure}\n\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\tvector plane,\n\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\txlabel={},\n\t\t\t\tylabel={},\n\t\t\t\txticklabels={,},\n\t\t\t\tyticklabels={,},\n\t\t\t\taxis line style={draw=none},\n\t\t\t\ttick style={draw=none},\n\t\t\t\tgrid=none,\n\t\t\t]\n\t\t\t\\pgftransformcm{0.8945}{-0.4472}{0.4472}{0.8945}{\\pgfpoint{0}{0}}\n\t\t\t\\node at (0,0) {\\includesvg[scale=0.75]{figures/linear_algebra/tapir_transform2}};\n\t\t\t\\addplot[thick, dashed] {0.5*\\x};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{Rotation by $\\theta$ such that the mirror line is aligned with the horizontal axis.}\n\t\\end{subfigure}\n\t\\hfill\n\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\tvector plane,\n\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\txlabel={},\n\t\t\t\tylabel={},\n\t\t\t\txticklabels={,},\n\t\t\t\tyticklabels={,},\n\t\t\t\taxis line style={draw=none},\n\t\t\t\ttick style={draw=none},\n\t\t\t\tgrid=none,\n\t\t\t]\n\t\t\t\\pgftransformcm{1}{0}{0}{-1}{\\pgfpoint{0}{0}}\n\t\t\t\\pgftransformcm{0.8945}{-0.4472}{0.4472}{0.8945}{\\pgfpoint{0}{0}}\n\t\t\t\\node at (0,0) {\\includesvg[scale=0.75]{figures/linear_algebra/tapir_transform2}};\n\t\t\t\\addplot[thick, dashed] {0.5*\\x};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{Mirroring across the mirror line.}\n\t\\end{subfigure}\n\t\\begin{subfigure}[c]{0.45\\textwidth}\n\t\t\\begin{tikzpicture}\n\t\t\t\\begin{axis}[\n\t\t\t\tvector plane,\n\t\t\t\twidth=6cm, height=6cm,\n\t\t\t\txlabel={},\n\t\t\t\tylabel={},\n\t\t\t\txticklabels={,},\n\t\t\t\tyticklabels={,},\n\t\t\t\taxis line style={draw=none},\n\t\t\t\ttick style={draw=none},\n\t\t\t\tgrid=none,\n\t\t\t]\n\t\t\t\\pgftransformcm{0.8945}{0.4472}{-0.4472}{0.8945}{\\pgfpoint{0}{0}}\n\t\t\t\\pgftransformcm{1}{0}{0}{-1}{\\pgfpoint{0}{0}}\n\t\t\t\\pgftransformcm{0.8945}{-0.4472}{0.4472}{0.8945}{\\pgfpoint{0}{0}}\n\t\t\t\\node at (0,0) {\\includesvg[scale=0.75]{figures/linear_algebra/tapir_transform2}};\n\t\t\t\\addplot[thick, dashed] {0.5*\\x};\n\t\t\t\\end{axis}\n\t\t\\end{tikzpicture}\n\t\t\\caption{Rotating back to the original orientation (i.e. by $-\\theta$).}\n\t\\end{subfigure}\n\t\\caption{Constructing a general $2\\times2$ reflection matrix as the composition of rotating, mirroring and rotating back.}\n\t\\label{fig:building_reflect_2x2}\n\\end{figure}\n\n\\subsection{Kernel and null space}\nWhile the determinant of a matrix tells us whether the matrix is reversible or not, it doesn't quantify the loss in dimensionality resulting from applying it: a matrix which \"squishes\" $\\Rs{3}$ in to a plane has the same determinant as a matrix which \"squishes\" it into a line or the the a single point (the origin): $0$. To find a measurement that does quantify this characteristic, we can look at the set of all vectors which the matrix (and thus the transformation it represents) map to $\\vec{0}$. We call this set the \\emph{kernel} of the matrix/transformation (denoted $\\ker(A)$ or $\\ker(T)$, respectively). More formally - given an $m\\times n$ matrix representing a transformation $T:\\Rs{n}\\to\\Rs{m}$,\n\\begin{equation}\n\t\\ker(A) = \\left\\{ \\vec{v}\\in\\Rs{n} \\mid A\\vec{v}=\\vec{0}_{m} \\right\\},\n\t\\label{eq:kernel_matrix}\n\\end{equation}\nand equivalently,\n\\begin{equation}\n\t\\ker(T) = \\left\\{ \\vec{v}\\in\\Rs{n} \\mid T \\left( \\vec{v} \\right) =\\vec{0}_{m} \\right\\}\n\t\\label{eq:kernel_transformation}\n\\end{equation}\n\nIn the language of matrices, the kernel is sometimes refered to as their \\emph{null space}.\n\n\\begin{note}{Matrix/Transformation duality}{}\n\tFrom now on in this subsection we will discuss matrices only, however everything discussed here can be applied directly to the transformations they represent. We also use the term kernel instead of null space, as these two concepts are practially equivalent in our context.\n\\end{note}\n\n\\begin{example}{Kernel of a matrix}{}\n\tThe vector\n\t\\[\n\t\t\\vec{v}=\\colvec{0;-2;1}\n\t\\]\n\tis in the kernel of the matrix\n\t\\[\n\t\tA=\n\t\t\\begin{bmatrix}\n\t\t\t 0 & 1 & 2\\\\\n\t\t\t-1 & 3 & 6\\\\\n\t\t\t 2 & 2 & 4\\\\\n\t\t\\end{bmatrix},\n\t\\]\n\tsince\n\t\\begin{align*}\n\t\tA\\vec{v} &= \n\t\t\\begin{bmatrix}\n\t\t\t 0 & 1 & 2\\\\\n\t\t\t-1 & 3 & 6\\\\\n\t\t\t 2 & 2 & 4\\\\\n\t\t \\end{bmatrix}\\colvec{0;-2;1}\\\\\n\t\t\t\t &= \\colvec{0\\cdot0+1\\cdot(-2)+2\\cdot1;-1\\cdot0+3\\cdot(-2)+6\\cdot1;2\\cdot0+2\\cdot(-2)+4\\cdot1}\\\\\n\t\t\t\t &= \\colvec{0-2+2;0-6+6;0-2+4}\\\\\n\t\t\t\t &= \\colvec{0;0;0}.\n\t\\end{align*}\n\\end{example}\n\nTwo properties of the kernel of a matrix are relatively straight-forward:\n\\begin{itemize}\n\t\\item The (dimentially correct) zero vector is always in the kernel of any matrix. This is because the zero vector of a transformation's domain is always mapped to the zero vector in its image (stated in \\autoref{sec:intuitive_linear_trans} as the fact that linear transformations preserve the origin).\n\t\\item Any linear combination of vectors in the kernel of a matrix is also in the kernel of the matrix. This is easily proved using the basic properties of linear transformations (which we show in matrix form):\n\\begin{proof}{Linear combinations of kernel vectors}{}\n\tLet $A$ be a matrix, and $\\vec{u},\\vec{v}$ two vectors in its kernel. Then\n\t\\begin{align*}\n\t\tA\\cdot \\left( \\alpha\\vec{u}+\\beta\\vec{v} \\right) &= A\\cdot \\left( \\alpha\\vec{u} \\right) + A\\cdot \\left( \\beta\\vec{v} \\right)\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &= \\alpha A\\vec{u} + \\beta A\\vec{v}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &= \\alpha\\vec{0} + \\beta\\vec{0}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &= \\vec{0} + \\vec{0}\\\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t &= \\vec{0}.\n\t\\end{align*}\n\tTherefore $\\vec{w}=\\alpha\\vec{u}+\\beta\\vec{v}$ is also in the kernel of $A$.\n\\end{proof}\n\\end{itemize}\n\nThe kernel of a matrix forms a subspace of its domain (see \\autoref{fig:kernel_subspace}). Therefore, we can quantify the dimension of the kernel, sometimes called its \\emph{nullity}:\n\\begin{equation}\n\t\\Null(A) = \\dim(\\ker(A)).\n\t\\label{eq:nullity}\n\\end{equation}\n\n\\begin{example}{Kernel space of a matrix}{}\n\tThe matrix\n\t\\[\n\t\tA=\n\t\t\\begin{bmatrix}\n\t\t\t0 & 1 & 2\\\\\n\t\t\t0 & 2 & 4\\\\\n\t\t\t0 & -3 & -6\\\\\n\t\t\\end{bmatrix} \n\t\\]\n\thas the following two vectors in its kernel:\n\t\\[\n\t\t\\vec{u}=\\colvec{1;0;0},\\ \\vec{v}=\\colvec{0;-2;1}.\n\t\\]\n\tThese two vectors are linearly independant, and span the kernel of $A$, having dimension $\\dim(V)=2$. All the vectors in $\\ker(A)$ are of the form\n\t\\[\n\t\t\\vec{w} = \\alpha\\vec{u} + \\beta\\vec{v},\n\t\\]\n\ti.e. the linear combinations of $\\vec{u}$ and $\\vec{v}$.\n\\end{example}\n\nAll the vectors which are not in $\\ker(A)$ also span a subspace of its domain, called the \\emph{column space} of $A$. The dimension of the column space is called the \\emph{rank} of $A$, $\\rank(A)$. The kernel and column space of a matrix are complementary: together they span $\\Rs{n}$.\n\nThis means that we can split the domain of a matrix to two separate subspaces, which together give us a lot of information about the image of the matrix: in one subspace are all the vectors that will be \"squished\" by the transformation into the origin, and the other subspace is composed of all the vectors that are transformed to a non-zero vector. If we limit the domain of the transformation to its column space, it becomes reversible - no two vectors in the column space are mapped to a single vector. On the other hand, the transformation on the kernel is always inversible.\n\nAlltogether, the nullity and rank of a matrix add up to the dimension of its domain, i.e.\n\\begin{equation}\n\t\\Null(A) + \\rank(A) = n.\n\t\\label{eq:}\n\\end{equation}\n\n\\begin{figure}[]\n\t\\centering\n\t\\begin{tikzpicture}\n\t\t\\node[ellipse, draw=black, thick, fill=xred!50, minimum width=2cm, minimum height=4cm, label={[label distance=-1cm]90:$\\Rs{n}$}] (domain) {};\n\t\t\\node[circle, draw=black, thick, fill=xblue!50, minimum size=1cm] (kernel) {$\\ker(A)$};\n\n\t\t\\node[ellipse, draw=black, thick, fill=xgreen!50, minimum width=2cm, minimum height=3cm, label={[label distance=-1cm]90:$\\Rs{m}$}] (image) at (4cm,0) {};\n\t\t\\node[circle, fill=black] (zero) at (4cm,0) {};\n\t\t\\node[right=of zero, xshift=-1cm] {$\\vec{0}$};\n\n\t\t\\draw[thick, densely dotted] (domain.north) -- (image.north);\n\t\t\\draw[thick, densely dotted] (domain.south) -- (image.south);\n\t\t\\draw[thick, densely dotted] (kernel.north) -- (zero.north);\n\t\t\\draw[thick, densely dotted] (kernel.south) -- (zero.south);\n\n\t\t\\draw[vector] (1,2.3) -- node [midway, above] {$A$} ++(2,0);\n\t\\end{tikzpicture}\n\t\\caption{The kernel of a matrix $A$ is a subspace of its domain $\\Rs{n}$. It is mapped exclusively to $\\vec{0}_{m}$ in its image. The set $\\Rs{n}\\setminus\\ker(A)$, i.e. $\\Rs{n}$ minus the kernel (shown in red), is in fact the column space of the matrix.}\n\t\\label{fig:kernel_subspace}\n\\end{figure}\n\nTBD: figure to illustrate the kernel and column space of a matrix as complementary.\n\nIf the rank of an $m\\times n$ matrix $A$ is equal to $n$, its kernel space must have the dimension\n\\[\n\t\\Null(A) = n-\\rank(A) = n-n = 0,\n\\]\ni.e. the matrix has no vectors mapped to $\\vec{0}$ (except the zero vector itself), and thus the matrix is invertible (non-singular), and so its determinant is non-zero. This is true in the other direction: a matrix with non-zero determinant is invertible, and thus its kernel contains only $\\vec{0}$ and the nullity of the matrix is $0$. This means that the column space of the matrix must equal $n$. Alltogether, these facts can be written succinctly as\n\\begin{equation}\n\t\\rank(A) = n \\Leftrightarrow |A|\\neq0.\n\t\\label{eq:rank_det}\n\\end{equation}\n\n%TBW: how matrix-matrix product changes the right-side matrix (i.e. exchanging rows/columns, scaling, etc.).\n", "meta": {"hexsha": "4316e7e90d95a8827c35dd66be4f589a71bc9616", "size": 98816, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "chapters/linear_algebra_intuitive/matrices.tex", "max_stars_repo_name": "pelegs/maths_book", "max_stars_repo_head_hexsha": "d1bebf3516a5821772d8807ce3d222a3caff1360", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2021-12-25T20:02:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-08T17:57:59.000Z", "max_issues_repo_path": "chapters/linear_algebra_intuitive/matrices.tex", "max_issues_repo_name": "pelegs/maths_book", "max_issues_repo_head_hexsha": "d1bebf3516a5821772d8807ce3d222a3caff1360", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2022-01-17T05:01:10.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-20T06:18:24.000Z", "max_forks_repo_path": "chapters/linear_algebra_intuitive/matrices.tex", "max_forks_repo_name": "pelegs/maths_book", "max_forks_repo_head_hexsha": "d1bebf3516a5821772d8807ce3d222a3caff1360", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2022-01-17T10:15:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T10:45:13.000Z", "avg_line_length": 49.8064516129, "max_line_length": 727, "alphanum_fraction": 0.6414953044, "num_tokens": 38490, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.914900950352329, "lm_q2_score": 0.918480237330998, "lm_q1q2_score": 0.8403184420139628}} {"text": "\n\\subsection{Hydrogen wavefunctions}\nHydrogen wavefunctions $\\psi$ are solutions to the differential equation\n$${\\psi\\over n^2}=\\nabla^2\\psi+{2\\psi\\over r}$$\nwhere $n$ is an integer representing the quantization of total energy and\n$r$ is the radial distance of the electron.\nThe Laplacian operator in spherical coordinates is\n\n$$\\nabla^2={1\\over r^2}{\\partial\\over\\partial r}\n\\left(r^2{\\partial\\over\\partial r}\\right)\n+{1\\over r^2\\sin\\theta}{\\partial\\over\\partial\\theta}\n\\left(\\sin\\theta{\\partial\\over\\partial\\theta}\\right)\n+{1\\over r^2\\sin^2\\theta}{\\partial^2\\over\\partial\\phi^2}$$\n\nThe general form of $\\psi$ is\n\n$$\\psi=r^le^{-r/n}L_{n-l-1}^{2l+1}(2r/n)\nP_l^{|m|}(\\cos\\theta)e^{im\\phi}$$\n\nwhere $L$ is a Laguerre polynomial, $P$ is a Legendre polynomial and\n$l$ and $m$ are integers such that\n\n$$1\\le l\\le n-1,\\qquad -l\\le m\\le l$$\n\nThe general form can be expressed as the product of a radial\nwavefunction $R$ and a spherical harmonic $Y$.\n\n$$\\psi=RY,\\qquad R=r^le^{-r/n}L_{n-l-1}^{2l+1}(2r/n),\\qquad\nY=P_l^{|m|}(\\cos\\theta)e^{im\\phi}$$\n\nThe following script checks $E=K+V$ for $n,l,m=7,3,1$.\n\n\\begin{Verbatim}[formatcom=\\color{blue},samepage=true]\nlaplacian(f) = 1/r^2*d(r^2*d(f,r),r)+\n 1/(r^2*sin(theta))*d(sin(theta)*d(f,theta),theta)+\n 1/(r*sin(theta))^2*d(f,phi,phi)\nn = 7\nl = 3\nm = 1\nR = r^l*exp(-r/n)*laguerre(2*r/n,n-l-1,2*l+1)\nY = legendre(cos(theta),l,abs(m))*exp(i*m*phi)\npsi = R*Y\nE = psi/n^2\nK = laplacian(psi)\nV = 2*psi/r\nsimplify(E-K-V)\n\\end{Verbatim}\n\nThis is the result when the script runs.\n\n$\\displaystyle 0$\n", "meta": {"hexsha": "4782bd7a59fd497a42ea9778727a2cb04549fd18", "size": 1534, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/hydrogen-wavefunctions.tex", "max_stars_repo_name": "zhouxs1023/eigenmath", "max_stars_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "doc/hydrogen-wavefunctions.tex", "max_issues_repo_name": "zhouxs1023/eigenmath", "max_issues_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "doc/hydrogen-wavefunctions.tex", "max_forks_repo_name": "zhouxs1023/eigenmath", "max_forks_repo_head_hexsha": "e302cee23a4d5877ffe0975f513b35654fa50961", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5, "max_line_length": 73, "alphanum_fraction": 0.6727509778, "num_tokens": 606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.973240712157665, "lm_q2_score": 0.8633916152464016, "lm_q1q2_score": 0.8402878704933646}} {"text": "\n\\subsection{Maclaurin series}\n\nA Taylor series around \\(c=0\\).\n\n\\(f(x)=\\sum_{i=0}^\\infty (x-c)^i \\dfrac{f^i(c)}{i!}\\)\n\n\\(f(x)=\\sum_{i=0}^\\infty (x)^i \\dfrac{f^i(0)}{i!}\\)\n\nFor example, for:\t \n\n\\(f(x)=(1-x)^{-1}\\)\n\n\\(f^i(0)=i!\\)\n\nSo, around \\(x=0\\):\n\n\\(f(x)=\\sum_{i=0}^\\infty (x)^i\\)\n\n", "meta": {"hexsha": "b56d419f97f5eabc79f4f94f7b0a704e9b2c5241", "size": 287, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/analysis/transformations/02-03-maclaurin.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/analysis/transformations/02-03-maclaurin.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/analysis/transformations/02-03-maclaurin.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.35, "max_line_length": 53, "alphanum_fraction": 0.4947735192, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9504109784205502, "lm_q2_score": 0.8840392893839086, "lm_q1q2_score": 0.8402006459855685}} {"text": "\n\\subsection{Cayley's theorem}\n\nCayley's theorem states that every group \\(G\\) is isomorphic to a subgroup of the symmetric group acting on \\(G\\).\n\nMultiplication by a member of \\(G\\) is a bijective function, as for each \\(g\\) there is also a \\(g^{-1}\\).\n\nThis means that multiplication of each member of \\(G\\) is a permutation, and so is a subset of the symmetric group on \\(G\\).\n\n", "meta": {"hexsha": "6d65eda61e56bb365cc99e407c0817622aca32db", "size": 382, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/geometry/groups/06-01-cayley.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/geometry/groups/06-01-cayley.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/geometry/groups/06-01-cayley.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2, "max_line_length": 124, "alphanum_fraction": 0.7120418848, "num_tokens": 98, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9591542840900508, "lm_q2_score": 0.8757869948899665, "lm_q1q2_score": 0.8400148480990628}} {"text": "\n\\subsection{Basis vectors}\n\n\\subsubsection{Basis}\n\nWe can write vectors as combinations of other vectors.\n\n\\(v=\\sum_i \\alpha_i v_i\\)\n\nA subset which spans the vector space, and which is also linearly independent, is a basis of the vector space.\n\nFor an arbitrary vector of size \\(n\\), we cannot use less than \\(n\\) elementary vectors. We could use more, but these would be redundant.\n\nIf we use \\(n\\) elementary vectors, there is a unique solution of weights of elementary vectors.\n\nIf we use more than \\(n\\) elementary vectors, there will be linear dependence, and so there will not be a unique solution.\n\n", "meta": {"hexsha": "8506515ec8a2741518b15db04d2e11c7ce8fa488", "size": 608, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/geometry/linearAlgebra/01-04-linearCombinations.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/geometry/linearAlgebra/01-04-linearCombinations.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/geometry/linearAlgebra/01-04-linearCombinations.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7777777778, "max_line_length": 137, "alphanum_fraction": 0.7565789474, "num_tokens": 140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9518632329799586, "lm_q2_score": 0.8824278587245935, "lm_q1q2_score": 0.8399506344771737}} {"text": "\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amsmath,amssymb}\n\\newcommand\\setdef[2]{\\left\\{\\left.{#1}\\,\\right|\\,{#2}\\right\\}}\n\\newcommand\\card[1]{\\left|#1\\right|}\n\\begin{document}\n\n\\section[Probability space]{Probability space $(\\Omega, \\mathcal A, \\mathbb P)$}\n\\begin{description}\n \\item[$\\Omega$] is the set of outcomes ($n$-tuples, 1 of 365 days for $n$ people)\n \\[ \\Omega = \\left\\{(d_1, d_2, \\dots, d_n): 1 \\leq d_i \\leq 365 \\: \\forall i \\in \\{1, \\dots, n\\}\\right\\} \\]\n \\item[$\\mathcal A$] is the set of events (power set of $\\Omega$)\n \\[ \\mathcal A = \\mathcal P(\\Omega) \\]\n \\begin{align*}\n \\{\\} &\\in \\mathcal A \\\\\n \\Omega &\\in \\mathcal A \\\\\n \\{(d_1, d_2, \\dots, d_n): d_i = d_j \\text{ for any } i \\neq j\\} &\\in \\mathcal A \\\\\n \\{(d_1, d_2, \\dots, d_n): d_i \\neq d_j \\forall i \\neq j\\} &\\in \\mathcal A\n \\end{align*}\n \\item[$\\mathbb P$] is the probability measure for given $A \\in \\mathcal A$\n \\[ \\mathbb P(\\{\\}) = 0 \\]\n \\[ \\mathbb P(\\Omega) = 1 \\]\n \\[ \\mathbb P(\\{(d_1, d_2, \\dots, d_n): d_i \\neq d_j \\forall i \\neq j\\}) = \\frac{n! \\cdot {365 \\choose n}}{365^n} \\]\n \\[ \\mathbb P(\\{(d_1, d_2, \\dots, d_n): d_i = d_j \\text{ for any } i \\neq j\\}) = 1 - \\frac{n! \\cdot {365 \\choose n}}{365^n} \\]\n where ${365 \\choose n}$ is the number of possibilities to assign $n$ people to 365 dates without collision. Once you have chosen $n$ slots, there are $n!$ ways to permute the specific assignment for person $1$ to $n$. As usual we divide the number of desired outcomes by the number of possible outcomes. The possible outcomes are left. We have $365^n$ ways to assign one of $365$ days to $n$ people.\n\\end{description}\n\n\\subsection{Whiteboard solution for (a)}\n\\[ \\mathbb P((x_1, \\dots, x_n)) = 365^n \\]\n\\[ \\mathbb P(X \\geq 2) = 1 - \\mathbb P(X = 1) \\]\nEvent $A = \\setdef{(x_1, \\dots, x_n) \\in \\Omega}{\\text{at least two $x_i$ are equal}}$.\n\\[ A^C = \\setdef{(x_1, \\dots, x_n) \\in \\Omega}{x_i \\neq x_j, j \\neq i} \\]\n\\[ \\mathbb P(A^C) = \\frac{\\card{A^C}}{\\card{\\Omega}} = \\frac{365 \\cdot 364 \\cdot \\dots \\cdot (365-n+1)}{365^n} \\]\n\n\\section{Find $n$ such that $\\mathbb P(A) > 0.5$ with $|A| = 1$}\n\nUsing R:\n\n\\begin{verbatim}\n# via https://stackoverflow.com/a/40527881\nramanujan <- function(n){\n n*log(n) - n + log(n*(1 + 4*n*(1+2*n)))/6 + log(pi)/2\n}\nbignchoosek <- function(n,k){\n exp(ramanujan(n) - ramanujan(k) - ramanujan(n-k))\n}\nf <- function (n) { 1 - factorial(n) * bignchoosek(365, n)/365^n }\nf(5)\n# [1] 0.02713187\nfor (i in 1:365) {\n if (f(i) > 0.5) {\n print(i)\n break\n }\n}\n# [1] 23\n\\end{verbatim}\n\nUsing Python:\n\n\\begin{verbatim}\n>>> import math\n>>> fac = math.factorial\n>>> f = lambda n: 1 - fac(n) * (fac(365) / (fac(n) * fac(365 - n))) / 365.0**n\n>>> for i in range(1,365):\n... if f(i) > 0.5:\n... print(i)\n... break\n... \n23\n\\end{verbatim}\n\nAnswer: 23\n\n\\section{Find $n$ such that $\\mathbb P(A) > 0.99$ with $|A| = 1$}\n\nUsing R:\n\n\\begin{verbatim}\nfor (i in 1:365) {\n if (f(i) > 0.99) {\n print(i)\n break\n }\n}\n# [1] 57\n\\end{verbatim}\n\nUsing Python:\n\n\\begin{verbatim}\n>>> for i in range(1,365):\n... if f(i) > 0.99:\n... print(i)\n... break\n... \n57\n\\end{verbatim}\n\n\\end{document}", "meta": {"hexsha": "2c1ce755f17e75da0e8efc3bc71ca24e349c6413", "size": 3205, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "probability_theory_practicals/ex5/solution.tex", "max_stars_repo_name": "prokls/math-lecture-notes", "max_stars_repo_head_hexsha": "d1a94e128d13ce4399a9cc55323b2f8e0d9494fd", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2015-11-25T01:49:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-26T14:47:36.000Z", "max_issues_repo_path": "probability_theory_practicals/ex5/solution.tex", "max_issues_repo_name": "prokls/math-lecture-notes", "max_issues_repo_head_hexsha": "d1a94e128d13ce4399a9cc55323b2f8e0d9494fd", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2019-05-22T07:56:03.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-02T09:32:40.000Z", "max_forks_repo_path": "probability_theory_practicals/ex5/solution.tex", "max_forks_repo_name": "prokls/math-lecture-notes", "max_forks_repo_head_hexsha": "d1a94e128d13ce4399a9cc55323b2f8e0d9494fd", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-03-24T14:42:30.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-25T11:00:11.000Z", "avg_line_length": 32.05, "max_line_length": 403, "alphanum_fraction": 0.5803432137, "num_tokens": 1273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404057671712, "lm_q2_score": 0.903294216466424, "lm_q1q2_score": 0.8395581430796922}} {"text": "\\chapter{Functions}\n\n\\index{function}\n\nIn a pure mathematical sense, a function is defined as taking an input and determining some output based on that input. A function allows us to group a piece of code that we expect to re-use many times.\n\n\\section{Inputs and Outputs}\n\nA simple example might be a function that finds the absolute value of a number. That is, it gets rid of the negative sign if the number is negative, or else it leaves it alone.\n\n\\codejs{\\source{js/absolute.js}}\n\nLet's take a look at all the elements of how we create functions in JavaScript. The \\texttt{var absolute} is a variable just like any other variable. It is how we are going to refer to this particular function later on in the program. The assignment \\texttt{=} is simply stating that once I create the function, that variable will hold a reference to it.\\\\\n\n\\index{arguments of a function}\n\nNext, I use the \\texttt{function} keyword to state that I am defining a new function. What follows is an open and closed set of parenthesis. This defines the argument list to the function: the inputs to the function, and how I will refer to them from within the function. \\texttt{function(x)} means that this function will have 1 input, and we will refer to that input as \\texttt{x} within the function as if it is a variable. However, \\texttt{x} is not accessible outside the function, only inside of it.\\\\\n\nWhat follows the argument list is a set of open and closed curly brackets \\texttt{\\{\\}}. All of the code between these brackets is what is run whenever the function is called. This is where I put any of the control structures or calls to other functions I wish to occur to complete the task this function is supposed to perform.\\\\\n\n\\index{return statement}\n\nThe \\texttt{return} statement causes the function to stop executing the function code, and return immediately back to where the function was called. A single value can also be returned to that point as in this example. The absolute value function checks to see if the number is negative. If it is, it returns the negation of the number causing it to return a positive number. Otherwise it will return the original number, which I know must already be a positive number.\\\\\n\nI can put a \\texttt{return} statement in multiple places within the function code, but only one of them will be called during a particular call to the function since it will immediately terminate the function as soon as it's reached. So, if it returns the negation of a negative number inside the \\texttt{if} statement, it will never reach the other \\texttt{return} statement.\\\\\n\nAfter the closing bracket of the function is a semi-colon, which is placed there because of the assignment operation that assigned this function into the variable \\texttt{absolute}, just like every other assignment operation such as \\texttt{var z = 4;}.\\\\\n\nOnce the function is defined, I can call the function by referring to it using the \\texttt{absolute} variable. Calling the function is performed by placing an open and closed set of parenthesis with the values I wish the arguments to have inside the function, in exactly the same order as they appeared in the argument list when the function was defined. In this example I find the absolute value of \\texttt{-3.5} by calling the function with that as the value of the \\texttt{x} argument: \\texttt{absolute(-3.5)}. This is such a useful function that it is a part of JavaScript already, and can be called by referring to \\texttt{Math.abs(x)}.\\\\\n\n\\section{Function Scope}\n\n\\index{function scope}\n\nI can put any code inside a function that I wish, including defining new variables. However, when I define a variable in a function, that variable is not directly accessible outside of the function. This is called function scope. This prevents causing confusion when using the same variable name in different functions.\\\\\n\n\\codejs{\\source{js/sqrt.js}}\n\nThis example shows one particular way of approximately computing the square root of a number using iteration. JavaScript has a square root function already as \\texttt{Math.sqrt(x)}, but lets look at how this function works.\\\\\n\nIt begins just like the \\texttt{absolute} function, by declaring a new variable \\texttt{var sqrt = } to name the \\texttt{function}, and an argument list \\texttt{(...)} naming a single input \\texttt{x}. However, this \\texttt{x} is not the same as the previous \\texttt{x}. The argument is only referenced inside of the function, and since this is a different function the argument can have the same name.\\\\\n\nThe first thing done when the function is called is to declare a variable \\texttt{guess}, which will end up being the approximate value of the square root of the input. The initial value of \\texttt{guess} is not super important, but I know that the square root of a number is less than the number itself, so starting with a guess of half the original number is a good start.\\\\\n\nAnother variable \\texttt{max\\_error} is then declared to hold a value of how accurate I want the answer to be. I might be tempted to just put zero here, but if I did that then the function may not ever finish running! Basically, if I want a more accurate answer, the function will take longer to run since it will have to iterate more times. So, I just pick a value of the error that is small compared to the numbers I am interested in.\\\\\n\nThese variables are not accessible outside of the function. They don't exist until the function is called, and once the function stops they in effect disappear. So, if I want a variable declared in a function to have a particular value, then I have to assign it within the function. If I want to know what the value was once the function returns, then I have to make sure there is another way to access it, such as using the \\texttt{return} statement to return the value the variable contained.\\\\\n\nA while-loop control structure is then used to implement the iteration. The loop should continue to iterate until the error is less-than or equal to the maximum error that I specified. To do that, the square of the \\texttt{guess} is computed by multiplying it by itself, and then subtracting from what should be the true value of the square, which was the original number. If the guess was exactly equal to the square root of \\texttt{x}, then this difference would be zero. However, it could be more or less than the true value since it is only approximate.\\\\\n\nThe difference \\texttt{guess*guess - x} is then fed into the \\texttt{absolute()} function from earlier because the difference could be negative, and I only care about how big it is in magnitude so that I can use the comparison operator to see if it's bigger than the maximum error I want.\\\\\n\nNotice that I did some math inside of the argument list of the \\texttt{absolute()} function. That is ok! Before \\texttt{absolute} is called, all of the operations inside there are performed to result in a single number that is then assigned as the argument to the function, and only then is \\texttt{absolute} actually called. Also, notice that \\texttt{absolute} is really a variable declared outside of the \\texttt{sqrt} function, but I am referring to it from inside the \\texttt{sqrt} function. Function scope works like a one-way mirror: it can see all the variables declared outside, but no-one on the outside can see the variables that are inside.\\\\\n\nInside the while loop the \\texttt{guess} is made better by using some mathematical magic based on the previous guess and the original number. Every time through the loop the \\texttt{guess} gets closer and closer to the real deal, and eventually it's close enough that the loop condition causes the loop to stop.\\\\\n\nAfter the loop is done I just need to return the value of \\texttt{guess} back to where the function was called. At this point the variables \\texttt{guess} and \\texttt{max\\_error} can no longer be referenced from anywhere, but the returned value is assigned into the variable \\texttt{y} in this example, so that is where it is now stored.\\\\\n\n\\section{Recursion}\n\n\\index{recursion}\n\nThe code inside a function can call other functions, including itself. When a function calls itself, or results in another call to itself, this is called recursion. This is a form of iteration since the same code is executed repeatedly, and so must have some condition when it will stop, just like with a loop.\\\\\n\n\\codejs{\\source{js/factorial.js}}\n\nThis example shows a recursive function that computes the factorial of an integer: \\(n! = n(n-1)(n-2)...(3)(2)1\\). The first thing it does is see if the argument to the function is 0, since factorial of 0 is 1. If it's not 0, then it computes the factorial of 1 less than the argument by calling itself on \\texttt{n-1}, multiplies the result by \\texttt{n} and returns that. It can call itself because the variable \\texttt{factorial} is already defined, and the function will be defined before it gets called the first time.\\\\\n\nWhy does this work? The first time the function is called, the argument is equal to the number it's actually computing the factorial of. Say it's the number 5. We know that \\(5! = 5*4*3*2*1\\), and we noticed that \\(4! = 4*3*2*1\\). So we can re-write the original problem as \\(5! = 5*4!\\). Translating that into code means that the factorial of a number can be computed by calling the same function on 1 less than that number, and multiplying the result by the number.\\\\\n\nWhen the function is called the second time, the argument n has a value of 4. Technically speaking, the first call to the function hasn't even finished yet. It's waiting for the second call of the function to return before it can multiply by it's version of n to return the total answer. This is ok because every time the function is called it creates an entirely new \\texttt{n} to work with, so the computer doesn't get confused about which one is which. That is called a stack frame, and every recursive call creates a new frame on the stack of all the previous calls that are waiting on this particular call to the function to finish.\\\\\n\nTo complete this call, the same logic applies as the first time. \\(4! = 4 * 3!\\). This keeps working until it gets down to zero. \\(1! = 1 * 0!\\), but then what is \\(0!\\)? If we let the function keep doing the same thing it would think that \\(0! = 0 * (-1)!\\), and then \\((-1)! = (-1)*(-2)!\\) and so on. For one thing that's just wrong. For another, it would never stop! That is what the if-statement is for: it's a terminating condition for when it reaches 0.\\\\\n\nOnce the terminating condition is reached, it returns a value without having to call itself anymore. All the previous calls to the function on the call stack that are waiting can then be completed in the reverse order. \\texttt{factorial(0)} returns 1. Then \\texttt{factorial(1)} returns 1. Then \\texttt{factorial(2)} returns 2. \\texttt{factorial(3)} returns 6. \\texttt{factorial(4)} returns 24. And finally \\texttt{factorial(5)} returns 120, which was the first thing to get called and is the final answer.\\\\\n\nAs an exercise, lets see what would happen if we called \\texttt{factorial(-1)}? You can code it up and just see. But lets also think about it logically why what happens, happens. If the argument starts out as -1, the first thing it does is check to see if it's equal to 0. It's not, so it does the recursive call sending in \\texttt{n-1}, which is -2. As stated before, this will cause an infinite recursion because the terminating condition \\texttt{n === 0} will never be reached. However, it won't run forever. What will happen is that it continues to pile recursive calls onto the call stack, potentially thousands of times, but at some point the computer will say that the maximum size of the stack was reached and will terminate the program, called a stack overflow.\\\\\n\n\\section{Exception Handling}\n\n\\index{exceptions}\n\\index{throw statement}\n\nThe function call \\texttt{factorial(-1)} never returns, but it doesn't run forever either. It simply exhausts the resources of the computer and crashes the program. For one, factorial isn't really even defined for -1. So it shouldn't have even attempted to compute it. This is an undefined scenario. The way I might deal with that is by throwing an exception from THE function to tell whoever tried to compute \\((-1)!\\) that they're not suppose to do that.\\\\\n\n\\codejs{\\source{js/factorial_exception.js}}\n\nThe \\texttt{throw} keyword works similarly to \\texttt{return}: The function will stop executing, and a value will be associate with the termination. In this case I send a message about what happened. When something is thrown, however, it is an error, and causes what is called a program exception (something that isn't supposed to happen). If that exception is not handled by whatever called the function, then the whole program will terminate. This prevents the undefined behavior from happening unknown to anyone. The stack overflow was also an exception, but the exception I add should catch the problem sooner and give more information about what the issue is.\\\\\n\nThe way we can handle possible exceptions from a function is called a try-catch block. I put the code that might cause an exception inside the braces of the \\texttt{try}. If no exception occurs, then everything proceeds as if there is no exception handling at all. However, if that code results in an exception, then execution in the try block terminates, and the catch block begins executing and the \\texttt{err} argument contains the value that was specified at the \\texttt{throw} statement.\\\\\n\n\\index{try-catch}\n\n\\codejs{\\source{js/factorial_exception_handled.js}}\n\n\\section{Side-effects}\n\n\\index{side effects of a function}\n\nSince the code inside a function can access the variables declared outside of the function, it can also alter the values stored in those variables. Since those variables are not arguments to the function, nor are they assigned from the \\texttt{return} from the function, we call this type of alteration a \\textit{side-effect} of calling the function.\n\n\\codejs{\\source{js/increment.js}}\n\nIn this example \\texttt{increment} is a function that has no arguments, and does not return anything. However, when it is called it alters the variable \\texttt{i} by adding 1 to its current value. Since \\texttt{i} is declared outside of the function, it can be accessed directly even after the function returns.\\\\\n\nThis type of behavior is very useful and powerful, but it must be used carefully. Since side-effects can have consequences far away from where the function is actually called, as opposed to the return statement, and persist after the function returns, someone that didn't write the function may not understand what it's doing. Documentation should be used to describe what is happening if a function has side-effects.\\\\\n\n\\section{Closure}\n\n\\index{closure}\n\nA closure happens when one function is defined inside the scope of another function, but is still callable after the outer function has already returned. It is also a way of using the power of function side-effects without any of the dangers by containing the side effects to a particular function scope.\n\n\\codejs{\\source{js/increment_closure.js}}\n\nI've taken the code for the \\texttt{increment} function, and placed it inside another function called \\texttt{makeIncrement}. When \\texttt{makeIncrement} is called, it creates a new instance of \\texttt{increment}, which is returned. However, since \\texttt{increment} has to have access to the variable \\texttt{i} to work, a closure is formed around that function scope so that it still has access to the version of \\texttt{i} created at the same time the function was, even after \\texttt{makeIncrement} has returned.\\\\\n\nWhen \\texttt{makeIncrement} returns the inner function, it is stored in a new variable. Whenever that version of \\texttt{increment} is called it is working with its own version of \\texttt{i}. I can call \\texttt{makeIncrement} again, creating a new version of \\texttt{increment} with its own version of \\texttt{i}, independent of the other one. That is because each call to \\texttt{makeIncrement} creates its own scope, and a new closure when it returns.\\\\\n\nNo matter which order the two versions of the function are called, it remembers how many times that particular version has already been called independent from the other one. However, I cannot directly access the variable \\texttt{i} because it was inside the function scope of \\texttt{makeIncrement}. It is basically a hidden variable that can be used to keep track of some information between function calls, and so as the creator of \\texttt{makeIncrement} I don't have to worry about anyone messing with that variable or making any assumptions about it.\\\\", "meta": {"hexsha": "50bab6aa69aec7aea39a120da85ea1ae471ae997", "size": 16709, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "TeX_files/Functions.tex", "max_stars_repo_name": "kcdodd/ecsp-book", "max_stars_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-07-27T18:34:02.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-27T18:34:02.000Z", "max_issues_repo_path": "TeX_files/Functions.tex", "max_issues_repo_name": "kcdodd/ecsp-book", "max_issues_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TeX_files/Functions.tex", "max_forks_repo_name": "kcdodd/ecsp-book", "max_forks_repo_head_hexsha": "371e0e07140bc2fa5a8e3d424510900f368f885a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 139.2416666667, "max_line_length": 772, "alphanum_fraction": 0.7782033635, "num_tokens": 3820, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92522995296862, "lm_q2_score": 0.9073122244934722, "lm_q1q2_score": 0.8394724467959492}} {"text": "\n\\subsection{Assumtions}\n\nGenerally, k states, markov chain?\n\nAssumptions are:\n\n+ Lasting immunity\n+ No births/other deaths\n\nComponents:\n\n+ \\(S(t)\\) - Susceptible\n+ \\(I(t)\\) - Infected\n+ \\(R(t)\\) - Removed (recovered or died)\n\nProportion of people who recover each period - \\(\\gamma \\).\n\nEach period, infected can transmit to \\(\\beta \\) people. Total of \\(I\\beta \\).\n\nNot everyone susceptible though, so \\(I\\beta \\dfrac{S}{N}\\)\n\nDynamics:\n\n+ \\(\\dfrac{dR}{dt} = \\gamma I\\)\n+ \\(\\dfrac{dS}{dt} = -\\beta I \\dfrac{S}{N}\\)\n+ \\(\\dfrac{dI}{dt} = \\beta I \\dfrac{S}{N} - \\gamma I\\)\n\nNote that \\(dfrac{dR}{dt} + dfrac{dI}{dt} + \\dfrac{dS}{dt} = 0\\)\n\nWe can then work out \\(\\dfrac{dI}{dS}\\)\n\n\\(\\dfrac{dI}{dS} = \\dfrac{\\dfrac{dI}{dt}}{\\dfrac{dS}{dt}}\\)\n\n\\(\\dfrac{dI}{dS} = \\dfrac{\\beta I \\dfrac{S}{N} - \\gamma I}{-\\beta I \\dfrac{S}{N}}\\)\n\n\\(\\dfrac{dI}{dS} = \\dfrac{\\beta S - \\gamma N}{-\\beta S}\\)\n\n\\(\\dfrac{dI}{dS} = - 1 + \\dfrac{\\gamma }{\\beta }\\dfrac{N}{S}\\)\n\nWe can then work out \\(\\dfrac{dS}{dR}\\)\n\n\\(\\dfrac{dS}{dR} = \\dfrac{\\dfrac{dS}{dt}}{\\dfrac{dR}{dt}}\\)\n\n\\(\\dfrac{dS}{dR} = \\dfrac{-\\beta I \\dfrac{S}{N}}{\\gamma I}\\)\n\n\\(\\dfrac{dS}{dR} = -\\dfrac{\\beta }{\\gamma }\\dfrac{S}{N}\\)\n\nWe can rewrite the infection dynamic:\n\n+ \\(\\dfrac{dI}{dt} = \\beta I \\dfrac{S}{N} - \\gamma I\\)\n+ \\(\\dfrac{dI}{dt} = I(\\beta \\dfrac{S}{N} - \\gamma )\\)\n+ \\(\\dfrac{dI}{dt} = I\\gamma (\\dfrac{\\beta }{\\gamma }\\dfrac{S}{N} - 1)\\)\n\nThis means that outbreak if \\(\\dfrac{\\beta }{\\gamma } > \\dfrac{S}{N}\\)\n\n\\(R_0 = \\dfrac{\\beta }{\\gamma }\\)\n\nWhat is steady state?\n\n\\(\\dfrac{dI}{dt} = I(\\beta \\dfrac{S}{N} - \\gamma )\\)\n\n\\(\\dfrac{dI}{dt} = 0\\)\n\n\\(R_0 \\dfrac{S}{N} = 1 )\\)\n\n\\(\\dfrac{S}{N} = \\dfrac{1}{R_0} )\\)\n\n\\(\\dfrac{\\beta }{\\gamma } > \\dfrac{S}{N}\\)\n\n\n\\subsection{Vaccinations}\n\nWhat proportion need vaccination?\n\n\n", "meta": {"hexsha": "4281ec5a47bea6ba9e4b19f39c59c02a1d8c7908", "size": 1776, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/biology/SIR/01-01-SIR.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/biology/SIR/01-01-SIR.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/biology/SIR/01-01-SIR.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0649350649, "max_line_length": 83, "alphanum_fraction": 0.5698198198, "num_tokens": 769, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9566341975270267, "lm_q2_score": 0.8774767922879693, "lm_q1q2_score": 0.839424307038991}} {"text": "\\subsection{Fubini's Theorem for Z-simple Regions}\r\n\\noindent\r\nThere is another case of Fubini’s Theorem that arises in 3D.\\\\\r\n\\begin{theorem}[Fubini's Theorem for Z-simple Regions]\r\n\tLet $D \\subset \\mathbb{R}^3$ and let $\\Omega = \\left\\{(x,y,z) \\mid (x,y) \\in D, g(x,y) \\leq z \\leq h(x,y) \\right\\}$ be a z-simple region.\r\n\t\\begin{equation*}\r\n\t\t\\iiint\\limits_{\\Omega}{f(x,y,z)\\mathrm{d}V} = \\iint\\limits_{D}{\\int_{g(x,y)}^{h(x,y)}{f(x,y,z)\\mathrm{d}z}\\mathrm{d}A}\r\n\t\\end{equation*}\r\n\\end{theorem}\r\n\r\n\\noindent\r\nIn other words, dependent variables must be integrated before the independent variables on which they rely, but the order of integration of independent variables doesn't matter.\\\\\r\n\r\n\\noindent\r\nFor example, we an express the unit sphere as a z-simple region where $D = \\left\\{(x,y) \\mid x^2 + y^2 \\leq 1\\right\\}$ and $-\\sqrt{1 - x^2 - y^2} \\leq z \\leq \\sqrt{1 - x^2 - y^2}$. Note that $D$ is a Type I Region.\r\n\\begin{equation*}\r\n\tV_{\\text{sphere}} = \\int_{-1}^{1}{\\int_{-\\sqrt{1-x^2}}^{\\sqrt{1-x^2}}{\\int_{-\\sqrt{1-x^2-y^2}}^{\\sqrt{1-x^2-y^2}}{\\mathrm{d}z}\\mathrm{d}x}\\mathrm{d}x} = \\frac{4\\pi}{3}\r\n\\end{equation*}", "meta": {"hexsha": "08702181edf046895149f2f8c84a0362c3d20988", "size": 1125, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "multiCalc/multipleIntegrals/fubinisTheoremZSimpleRegions.tex", "max_stars_repo_name": "aneziac/Math-Summaries", "max_stars_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2020-03-26T06:20:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T17:38:45.000Z", "max_issues_repo_path": "multiCalc/multipleIntegrals/fubinisTheoremZSimpleRegions.tex", "max_issues_repo_name": "aneziac/Math-Summaries", "max_issues_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2020-03-28T17:44:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-07T04:47:03.000Z", "max_forks_repo_path": "multiCalc/multipleIntegrals/fubinisTheoremZSimpleRegions.tex", "max_forks_repo_name": "aneziac/Math-Summaries", "max_forks_repo_head_hexsha": "20a0efd79057a1f54e093b5021fbc616aab78c3f", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2020-04-10T05:41:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T15:21:12.000Z", "avg_line_length": 62.5, "max_line_length": 215, "alphanum_fraction": 0.6488888889, "num_tokens": 435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.956634196290671, "lm_q2_score": 0.8774767842777551, "lm_q1q2_score": 0.8394242982912727}} {"text": "The homogeneous rigid transform is an extremely useful tool used to represent various things in robotics. \nFirst, the rigid transform is defined as a transformation $T$ that when acting on any vector $v$, produces a transformed vector $T(v)$ of the form: \n\\begin{equation}\n\tT(v) = R v + t\n\\end{equation}\n\nwhere $R^T R^{-1}$, and $t$ is a vector giving the translation of the origin. \nThis concept can be represented in a form called a {\\it homogeneous transformation matrix}. \nA homogeneous transformation matrix $T \\in \\mathbb{R}^{4 \\times 4}$ is a member of special euclidean group $SE(3)$, and can be written in the form:\n\\begin{equation}\n\tT = \\begin{bmatrix}\n\t\tR & t \\\\\n\t\t\\bf{0} & 1\n\t\\end{bmatrix}\n\\end{equation}\nwhere $R \\in \\mathbb{R}^{3 \\times 3}$ is a rotation matrix, and $t \\in \\mathbb{R}^3$ is a translation vector. \nThe inverse of a homogeneous transformation matrix is:\n\\begin{align}\n\tT^{-1} &= \n\t\\begin{bmatrix}\n\t\tR^T & -R^Tt \\\\\n\t\t\\bf{0} & 1\n\t\\end{bmatrix} \\\\\n\tT T^{-1} &= \\bf{I}\n\\end{align}\nWhen using super and subscripts to specify the frames we are referring to, then $T_b^a = (T_a^b)^{-1}$.\nWe can use a homogeneous transformation to operate on homogeneous points $p, q \\in \\mathbb{R}^4$, \n\\begin{align}\n\tq &= Tp \\\\\n\t\\begin{bmatrix} \n\t\tx_q \\\\ \n\t\ty_q \\\\\n\t\tz_q \\\\\n\t\t1\n\t\\end{bmatrix}\n\t&= \\begin{bmatrix}\n\t\tR & t \\\\\n\t\t\\bf{0} & 1\n\t\\end{bmatrix} \n\t\\begin{bmatrix}\n\t\tx_p \\\\\n\t\ty_p \\\\\n\t\tz_p \\\\\n\t\t1\n\t\\end{bmatrix}.\n\\end{align}\n\nIn general, there are three interpretations for homogeneous transformations:\n\\begin{enumerate}\n\t\\item A description of relative orientation and translation between frames. \n\t\\item A coordinate transform between frames. \n\tSpecifically, $T_j^i$ is a transform from frame ${j}$ to frame ${i}$:\n\t\\begin{equation}\n\t\tP^i = T_j^i P^j\n\t\\end{equation}\n\t\\item A motion of a point (or a collection of points) within a single frame. For example, as we saw above point $p$ can be moved to point $q$:\n\t\\begin{align}\n\t\tq &= Tp \\\\\n\t\tP_2^i &= T_j^i P^i_1\n\t\\end{align}\n\tSimilarly, a homogeneous transform can represent a motion from one frame to another.\n\tSpecifically, $T_j^i$ moves frame $i$ to frame $j$. \n\\end{enumerate}\nIt is important to specify which of these interpretations you are using within your program, as it can get confusing what these transformations represent if people aren't on the same page. \n\nAdditionally, one must pay attention to the frame that the operand is in, as this determines the function of the transform to some degree. \n$P_2^i = T^i_j P_1^i$ is a motion that operates on point $P_1^i$ within frame $i$ whereas $P^i = T_j^i P^j$ is a coordinate transformation from $j$ to $i$, and therefore if we feed a point in frame $j$ to this transformation, the point will not move, but the coordinates will be transformed into frame $i$, which is often desired. \n\n\\subsection{Transforming between frames}\nWe can chain together homogeneous transforms to represent a traversal through frames. \n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.8\\textwidth]{images/frame_traversal.png}\n\t\\caption{Traversing through different coordinate frames represented by rigid transformation matrices.}\n\t\\label{fig: frames}\n\\end{figure}\n\nSay we want the transform from $a$ to $d$:\n\\begin{equation}\n\tT_d^a = T^a_b T^b_c T^c_d.\n\\end{equation}\nNotice that the bottom subscript and the following top subscript \"cancel\" out when multiplying frames together. \nAdditionally when composing transforms like this, the \"source\" frame (in this case $d$) is included in the right most transform, and the \"destination\" frame $a$, is included in the left most. \n\nUsing this knowledge we can represent frames that are related in this way by a pose graph, or pose tree consisting of parent and child relationships between each frame. \n\n\\begin{figure}[H]\n\t\\centering\n\t\\includegraphics[width=0.8\\textwidth]{images/pose_graph.png}\n\t\\caption{Frames and their transforms can be represented in graph form.}\n\t\\label{fig: poses}\n\\end{figure}", "meta": {"hexsha": "1abebc00b4ca4fb7248b4911653d67f5bb8d2b2f", "size": 3951, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/math/core/core_transform.tex", "max_stars_repo_name": "bkolligs/pyrobo", "max_stars_repo_head_hexsha": "341687cbed96f839fae682f9ec1c58524d7b35b4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-06-20T15:40:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-11T03:20:29.000Z", "max_issues_repo_path": "docs/math/core/core_transform.tex", "max_issues_repo_name": "bkolligs/pyrobo", "max_issues_repo_head_hexsha": "341687cbed96f839fae682f9ec1c58524d7b35b4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-07-06T01:31:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-31T00:05:39.000Z", "max_forks_repo_path": "docs/math/core/core_transform.tex", "max_forks_repo_name": "bkolligs/robotics-prototyping", "max_forks_repo_head_hexsha": "ac7766921c7e8b2c51792697ddf2166ab9a46c82", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.9456521739, "max_line_length": 332, "alphanum_fraction": 0.7266514806, "num_tokens": 1147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012732322216, "lm_q2_score": 0.8872045877523147, "lm_q1q2_score": 0.8391192287136076}} {"text": "\n\\subsection{Mean Squared Error (MSE) and Root Mean Squared Error (RMSE) of an estimator}\n\n\\subsubsection{Mean squared error}\n\nMean squared error\n\n\\(MSE = E[(\\hat \\theta - \\theta )^2]=E[((\\hat \\theta - E[\\hat \\theta ])+(E[\\hat \\theta ]-\\theta ))^2]\\)\n\n\\(MSE = E[(\\hat \\theta - \\theta )^2]=E[(\\hat \\theta - E[\\hat \\theta ])^2+(E[\\hat \\theta ]-\\theta )^2+2(E[\\hat \\theta ]-\\theta )(\\hat \\theta- E[\\hat \\theta ])]\\)\n\n\\(MSE = E[(\\hat \\theta - \\theta )^2]=E[(\\hat \\theta - E[\\hat \\theta ])^2]+E[(E[\\hat \\theta ]-\\theta)^2] +E[2(E[\\hat \\theta ]-\\theta )(\\hat \\theta- E[\\hat \\theta ])]\\)\n\n\\(MSE = E[(\\hat \\theta - \\theta )^2]=Var(\\hat \\theta )+(E[\\hat \\theta ]-\\theta)^2 +2(E[\\hat \\theta ]-\\theta )E[\\hat \\theta- E[\\hat \\theta ]]\\)\n\n\\(MSE = E[(\\hat \\theta - \\theta )^2]=Var(\\hat \\theta )+Bias (\\hat \\theta )^2\\)\n\n\\subsubsection{Root Mean Square Error (RMSE)}\n\nThis is the square root of the MSE.\n\nIt is also called the Root Mean Square Deviation (RMSD)\n\n", "meta": {"hexsha": "3a764255198607bc903c4ffb9fbfb652651ea705", "size": 947, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "src/pug/theory/statistics/generative/02-02-MSE.tex", "max_stars_repo_name": "adamdboult/nodeHomePage", "max_stars_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pug/theory/statistics/generative/02-02-MSE.tex", "max_issues_repo_name": "adamdboult/nodeHomePage", "max_issues_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-03-03T12:36:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-01T22:16:09.000Z", "max_forks_repo_path": "src/pug/theory/statistics/generative/02-02-MSE.tex", "max_forks_repo_name": "adamdboult/nodeHomePage", "max_forks_repo_head_hexsha": "266bfc6865bb8f6b1530499dde3aa6206bb09b93", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.4583333333, "max_line_length": 166, "alphanum_fraction": 0.5923970433, "num_tokens": 353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.942506726044381, "lm_q2_score": 0.8902942217558213, "lm_q1q2_score": 0.8391082921633093}} {"text": "\\section{Linear Systems of Equations}\n\\label{sec:linearequations}\n\n(Real numbers only this time.)\n\nLinear equations are of the form $Ax = b$ where $A$ is a matrix and $x$ and $b$ are vectors. The rows of $A$ and $b$ form a system of equations that must be simultaneously satisfied by the entries of $x$. If $x,b\\in\\mathbb{R}^n$, then the solutions to the equation of a single row corresponds to an $n-1$-dimensional hyperplane. If the rows of $A$ are linearly independent, then solutions that simultaneously satisfy the equations in $k$-rows correspond to the $n-k$-dimensional intersection of $k$ $n$-dimensional hyperplanes. The solution of $x$ that satisfies all $n$ equations is a $n-n = 0$-dimensional point, and so $x$ is uniquely determined. If any two rows of $A$ are not linearly independent, then the hyperplanes that correspond to values of $x$ that satisfy them overlap exactly, and their intersection is $n$ dimensional, rather than $n-1$ dimensional. In this case, the value of $x$ that satisfies all rows of $A$ is not narrowed down to a single point. The system of equations is said to be *underdetermined*:. This is equivalently the case when $A$ has $mn$ rows, then there need not be any point $x\\in\\mathbb{R}^n$ in which the $m$ hyperplanes all intersect. In that case, the system does not have a solution $x\\in\\mathbb{R}^n$, and the system is considered *overdetermined*. (The intersection of $m$ distinct hyperplanes in $n$ dimensional space would have negative dimension $(n-m)<0$ if $m>n$, which my feeble brain can't make sense of.)\n\\\\\n\nIn the overdetermined case $A^{mxn}$ with $m>n$, the columns of $A$ do not span $\\mathbb{R}^m$ and therefore $b\\in\\mathbb{R}^m$ may have some component $\\epsilon$ that lies outside of the column space of $A$. In that case, no linear combination $x$ of the columns of $A$ can express $b$ perfectly, but we might look for approximate solutions $\\hat{x}$ so that:\n\n\\begin{equation}\nA\\hat{x} + \\epsilon = b\n\\end{equation}\n\nSo that the error $||\\epsilon||_{\\alpha}$ is minimized. This is the starting point for linear regression from the linear algebra perspective. In practice, the approximation is usually approximated by applying an iterative gradient descent algorithm to minimize the \\textit{loss function} $||\\epsilon||_{\\alpha}$. The choice of metric $||\\cdot||_{\\alpha}$ is essentially a design choice. For $\\alpha=2$, the metric is the $L^2$ norm (cf. section \\ref{sec:l2norm}) and an analytic solution exists, named the \\textit{normal equations}. The solution minimizes the least squares error and corresponds to the projection of $\\mathbf{b}$ into the column space of $a$. The procedure is better known as ordinary least squares regression and therefore I will move a more elaborate discussion to chapter \\ref{chap:linearregression}.\n\n\\subsection{$A\\in\\mathbb{R}^{n\\times m}$ Rectangular Matrices, Underdetermined Case}\nFor an underdetermined system with $m