Skip to content
Permalink
fc517f15b1
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
102 lines (77 sloc) 1.81 KB
%define values for E,F,G
e3 = [3;4];
f3 = [1;4;5];
g3 = [2;7];
%Call lu_tridiag
[ud3,uo3,lo3] = lu_tridiag(e3,f3,g3);
b3 = ones(3,1);
%Call solve_tridiag
x3 = solve_tridiag(ud3,uo3,lo3,b3);
x3_2 = (A3*3) \ b3;
error3 = x3 - x3_2;
normErr(3) = norm(err_3);
e4 = [1;1;3];
f4 = [2;2;5;8];
g4 = [4;5;6];
[ud4,uo4,lo4] = lu_tridiag(e4,f4,g4);
b4 = ones(4,1);
x4 = solve_tridiag(ud4,uo4,lo4,b4);
x4_2 = (A4*4) \ b4;
err_4 = x4 - x4_2;
normErr(4) = norm(err_4);
e5 = [3;4;4;4];
f5 = [1;2;4;4;9];
g5 = [1;3;3;9];
[ud5,uo5,lo5] = lu_tridiag(e5,f5,g5);
b5 = ones(5,1);
x5 = solve_tridiag(ud5,uo5,lo5,b5);
x5_2 = (A5*5) \ b5;
err_5 = x5 - x5_2;
normErr(5) = norm(err_5);
e6 = [1;3;4;5;6];
f6 = [2;2;7;7;9;10];
g6 = [3;4;5;9;9];
[ud6,uo6,lo6] = lu_tridiag(e6,f6,g6);
b6 = ones(6,1);
x6 = solve_tridiag(ud6,uo6,lo6,b6);
x6_2 = (A6*6) \ b6;
err_6 = x6 - x6_2;
normErr(6) = norm(err_6);
e7 = [1;1;2;4;4;5];
f7 = [3;3;5;8;8;9;9];
g7 = [2;2;4;4;6;7];
[ud7,uo7,lo7] = lu_tridiag(e7,f7,g7);
b7 = ones(7,1);
x7 = solve_tridiag(ud7,uo7,lo7,b7);
x7_2 = (A7*7) \ b7;
err_7 = x7 - x7_2;
normErr(7) = norm(err_7);
e8 = [1;1;2;2;2;3;5];
f8 = [1;2;4;6;6;9;10;10];
g8 = [2;4;6;7;8;9;9];
[ud8,uo8,lo8] = lu_tridiag(e8,f8,g8);
b8 = ones(8,1);
x8 = solve_tridiag(ud8,uo8,lo8,b8);
x8_2 = (A8*5) \ b8;
err_8 = x8 - x8_2;
normErr(8) = norm(err_8);
e9 = [1;1;2;3;3;4;4;6];
f9 = [2;3;3;4;5;8;8;9;10];
g9 = [1;2;2;4;5;5;7;9];
[ud9,uo9,lo9] = lu_tridiag(e9,f9,g9);
b9 = ones(9,1);
x9 = solve_tridiag(ud9,uo9,lo9,b9);
x9_2 = (A9*9) \ b9;
err_9 = x9 - x9_2;
normErr(9) = norm(err_9);
e10 = [1;1;2;2;3;4;5;6;6];
f10 = [1;2;2;3;4;5;6;8;8;9];
g10 = [1;3;4;6;7;7;7;8;9];
[ud10,uo10,lo10] = lu_tridiag(e10,f10,g10);
b10 = ones(10,1);
x10 = solve_tridiag(ud10,uo10,lo10,b10);
x10_2 = (A10*10) \ b10;
err_10 = x10 - x10_2;
normErr(10) = norm(err_10);
%Print error values
normErr'