2013-04-27 59 views
1

我有一個有100001個變量(x1到x100000和alpha)的方程組,並且有許多方程。有沒有一種計算有效的方法,用Matlab或其他方法來解決這個方程組。我知道solve()命令,但我想知道是否有更快的運行。方程是以下形式:在Matlab中快速求解方程的符號系統

1.)  -x1 + alpha * (x4 + x872 + x9932) = 0 
     . 
     . 
     . 
100000.) -x100000 + alpha * (x38772 + x95) = 0 

換言之,第i ^個方程有可變XI與係數-1加入到阿爾法*(某些其他變量的總和)等於0的最終方程僅僅是X1 + ... + x100000 = 1

+0

'alpha'也是未知的,不是嗎? – 2013-04-27 19:46:47

+0

是的,我更新了問題以反映這一點。 – user1748601 2013-04-27 19:51:54

回答

3

數學運算部分

該系統可以總是帶到本徵[值/矢量方程式規範形式:

** A ** * x * =λ X

其中是你的系統的矩陣,和X = [X1 ; x2; ...; x100000]。以從該question的例子中,該系統可以寫下來爲:

/    \ / \   / \ 
| 0 1 0 0 0 | | x1 |    | x1 | 
| 0 0 1 0 1 | | x2 |    | x2 | 
| 1 0 0 0 0 | x | x3 | = (1/alpha) | x3 | 
| 0 0 1 0 0 | | x4 |    | x4 | 
| 0 1 0 1 0 | | x5 |    | x5 | 
\    / \ /   \ /

這意味着你的特徵值和拉姆達; = 1/α。當然,你應該提防複雜的特徵值(除非你真的想把它們考慮進去)。

Matlab的部分

嗯,這是多少你的口味和技能。您始終可以通過eig()找到矩陣的特徵值。最好使用稀疏矩陣(記憶經濟):

N = 100000; 
A = sparse(N,N); 
% Here's your code to set A's values 
A_lambda = eig(A); 

ieps= 0e-6; % below this threshold imaginary part is considered null 
alpha = real(1 ./ (A_lambda(arrayfun(@(x) imag(x)<ieps, A_lambda)))); % Chose Real. Choose Life. Choose a job. Choose a career. Choose a family. Choose a f****** big television, choose washing machines, cars, compact disc players and electrical tin openers. Choose good health, low cholesterol, and dental insurance. Choose fixed interest mortgage repayments. Choose a starter home. Choose your friends. Choose leisurewear and matching luggage. Choose a three-piece suit on hire purchase in a range of f****** fabrics. Choose DIY and wondering who the f*** you are on a Sunday morning. Choose sitting on that couch watching mind-numbing, spirit-crushing game shows, stuffing f****** junk food into your mouth. Choose rotting away at the end of it all, pissing your last in a miserable home, nothing more than an embarrassment to the selfish, f***** up brats you spawned to replace yourself. Chose life. 

% Now do your stuff with alpha here 

但是,記住,這:數值求解大特徵方程可能會給你真正的地方,預計複數值。調整你的ieps爲明智的價值觀,如果你在開始時沒有找到任何東西。

要找到特徵向量,只需從系統中取出一個,並通過克萊默法則解決其餘問題。如果你願意的話,他們可以規範一個。