【问题标题】:Fast way for solving symbolic system of equations in MatlabMatlab中求解符号方程组的快速方法
【发布时间】:2013-04-28 10:41:24
【问题描述】:

我有一个包含 100001 个变量(x1 到 x100000 和 alpha)的方程组以及那么多方程。在 Matlab 或其他方面,是否有一种计算有效的方法来求解这个方程组。我知道 solve() 命令,但我想知道是否有一些运行得更快的东西。方程的形式为:

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

换句话说,第 i^th 方程有变量 xi,系数 -1 添加到 alpha *(一些其他变量的总和)等于 0。最终方程就是 x1 + ... + x100000 = 1。

【问题讨论】:

  • alpha 也是未知数,不是吗?
  • 是的,我更新了问题以反映这一点。

标签: matlab equation


【解决方案1】:

数学部分

这个系统可能总是被带到特征[值/向量]方程的规范形式:

**A***x* = λx

其中 A 是系统的矩阵,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 调整为合理的值。

要找到特征向量,只需从系统中取出一个,然后通过克莱默规则求解其余的。如果您愿意,可以将它们合二为一。

【讨论】:

    猜你喜欢
    • 2016-10-14
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    相关资源
    最近更新 更多