求解线性方程 [英] Solving a linear equation
问题描述
我需要以编程方式求解C,Objective C或(如果需要)C ++中的线性方程组.
I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++.
这是等式的一个示例:
-44.3940 = a * 50.0 + b * 37.0 + tx
-45.3049 = a * 43.0 + b * 39.0 + tx
-44.9594 = a * 52.0 + b * 41.0 + tx
因此,我想获得a
,b
和tx
的最佳近似值.
From this, I'd like to get the best approximation for a
, b
, and tx
.
推荐答案
克莱默规则 和 高斯消除 是两种很好的通用算法(另请参见同时线性方程式).如果您正在寻找代码,请查看 GiNaC , SymbolicC ++ (当然,这取决于您的许可要求).
Cramer's Rule and Gaussian Elimination are two good, general-purpose algorithms (also see Simultaneous Linear Equations). If you're looking for code, check out GiNaC, Maxima, and SymbolicC++ (depending on your licensing requirements, of course).
I know you're working in C land, but I also have to put in a good word for SymPy (a computer algebra system in Python). You can learn a lot from its algorithms (if you can read a bit of python). Also, it's under the new BSD license, while most of the free math packages are GPL.
这篇关于求解线性方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!