// ----------------------------------------------------------- // Seidel関数の使用例(例題5の連立方程式Ax=bの解:表5.2に同じ) // ----------------------------------------------------------- clear; // 定義済みの変数を消去 exec('Seidel.sci'); // Seidel関数の読み込み A = [ 10, 3, 1, 2, 1; // Ax=bの係数行列Aの定義 1,19, 2,-1, 5; -1, 1,30, 1,10; -2, 0, 1,20, 5; -3, 5, 1,-2,25 ]; b = [-22, 27, 89,-73, 22]'; // Ax=bの縦ベクトルbの定義 x0 = [ 0, 0, 0, 0, 0]'; // 解の初期値 tol = 1.0e-8; // xの差のノルムの2乗の許容量 itr = 100; // 最大繰り返し回数 x = Seidel( A, b, x0, tol, itr ) // Seidel関数の実行 // ↑ セミコロン(;)をつけていないので解xが表示される