Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add lect 12
  • Loading branch information
rcc02007 committed Feb 28, 2017
1 parent 05acb2b commit 903cb54
Show file tree
Hide file tree
Showing 14 changed files with 2,084 additions and 1 deletion.
Expand Up @@ -768,7 +768,89 @@
"### *just checked in to see what condition my condition was in*\n",
"### Matrix norms\n",
"\n",
"The Euclidean norm of a vector is measure of the magnitude (in 3D this would be: $|x|=\\sqrt{x_{1}^{2}+x_{2}^{2}+x_{3}^{2}}$) in general t"
"The Euclidean norm of a vector is measure of the magnitude (in 3D this would be: $|x|=\\sqrt{x_{1}^{2}+x_{2}^{2}+x_{3}^{2}}$) in general the equation is:\n",
"\n",
"$||x||_{e}=\\sqrt{\\sum_{i=1}^{n}x_{i}^{2}}$\n",
"\n",
"For a matrix, A, the same norm is called the Frobenius norm:\n",
"\n",
"$||A||_{f}=\\sqrt{\\sum_{i=1}^{n}\\sum_{i=1}^{m}A_{i,j}^{2}}$\n",
"\n",
"In general we can calculate any $p$-norm where\n",
"\n",
"$||A||_{p}=\\sqrt{\\sum_{i=1}^{n}\\sum_{i=1}^{m}A_{i,j}^{p}}$\n",
"\n",
"so the p=1, 1-norm is \n",
"\n",
"$||A||_{1}=\\sqrt{\\sum_{i=1}^{n}\\sum_{i=1}^{m}A_{i,j}^{1}}=\\sum_{i=1}^{n}\\sum_{i=1}^{m}|A_{i,j}|$\n",
"\n",
"$||A||_{\\infty}=\\sqrt{\\sum_{i=1}^{n}\\sum_{i=1}^{m}A_{i,j}^{\\infty}}=\\max_{1\\le i \\le n}\\sum_{j=1}^{m}|A_{i,j}|$\n",
"\n",
"### Condition of Matrix\n",
"\n",
"The matrix condition is the product of \n",
"\n",
"$Cond(A) = ||A||\\cdot||A^{-1}||$ \n",
"\n",
"So each norm will have a different condition number, but the limit is $Cond(A)\\ge 1$\n",
"\n",
"An estimate of the rounding error is based on the condition of A:\n",
"\n",
"$\\frac{||\\Delta x||}{x} \\le Cond(A) \\frac{||\\Delta A||}{||A||}$\n",
"\n",
"So if the coefficients of A have accuracy to $10^{-t}\n",
"\n",
"and the condition of A, $Cond(A)=10^{c}$\n",
"\n",
"then the solution for x can have rounding errors up to $10^{c-t}$\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A =\n",
"\n",
" 1.00000 0.50000 0.33333\n",
" 0.50000 0.33333 0.25000\n",
" 0.33333 0.25000 0.20000\n",
"\n",
"L =\n",
"\n",
" 1.00000 0.00000 0.00000\n",
" 0.50000 1.00000 0.00000\n",
" 0.33333 1.00000 1.00000\n",
"\n",
"U =\n",
"\n",
" 1.00000 0.50000 0.33333\n",
" 0.00000 0.08333 0.08333\n",
" 0.00000 -0.00000 0.00556\n",
"\n"
]
}
],
"source": [
"A=[1,1/2,1/3;1/2,1/3,1/4;1/3,1/4,1/5]\n",
"[L,U]=LU_naive(A)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"invA="
]
},
{
Expand Down
27 changes: 27 additions & 0 deletions lecture_12/LU_naive.m
@@ -0,0 +1,27 @@
function [L, U] = LU_naive(A)
% GaussNaive: naive Gauss elimination
% x = GaussNaive(A,b): Gauss elimination without pivoting.
% input:
% A = coefficient matrix
% y = right hand side vector
% output:
% x = solution vector
[m,n] = size(A);
if m~=n, error('Matrix A must be square'); end
nb = n;
L=diag(ones(n,1));
U=A;
% forward elimination
for k = 1:n-1
for i = k+1:n
fik = U(i,k)/U(k,k);
L(i,k)=fik;
U(i,k:nb) = U(i,k:nb)-fik*U(k,k:nb);
end
end
%% back substitution
%x = zeros(n,1);
%x(n) = Aug(n,nb)/Aug(n,n);
%for i = n-1:-1:1
% x(i) = (Aug(i,nb)-Aug(i,i+1:n)*x(i+1:n))/Aug(i,i);
%end
Binary file added lecture_12/chol_pre.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_12/det_L.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions lecture_12/lecture_12.aux
@@ -0,0 +1,27 @@
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldcontentsline\contentsline
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\contentsline\oldcontentsline
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\providecommand\HyField@AuxAddToCoFields[2]{}
\providecommand \oddpage@label [2]{}
\@writefile{toc}{\contentsline {subsection}{\numberline {0.1}My question from last class}{1}{subsection.0.1}}
\newlabel{my-question-from-last-class}{{0.1}{1}{My question from last class}{subsection.0.1}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces q1\relax }}{1}{figure.caption.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {0.2}Your questions from last class}{1}{subsection.0.2}}
\newlabel{your-questions-from-last-class}{{0.2}{1}{Your questions from last class}{subsection.0.2}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces q2\relax }}{2}{figure.caption.2}}
\@writefile{toc}{\contentsline {section}{\numberline {1}Matrix Inverse and Condition}{2}{section.1}}
\newlabel{matrix-inverse-and-condition}{{1}{2}{Matrix Inverse and Condition}{section.1}{}}

0 comments on commit 903cb54

Please sign in to comment.