2013-04-27 34 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为明智的价值观,如果你在开始时没有找到任何东西。

要找到特征向量,只需从系统中取出一个,并通过克莱默法则解决其余问题。如果你愿意的话,他们可以规范一个。