Fortran Code for Solving Linear System w/ Least Square Method

Click For Summary
SUMMARY

The discussion focuses on solving linear systems using the least squares method in Fortran. When the matrix A is ill-conditioned and the vector y contains disturbances, traditional methods fail to yield accurate results. The recommended approach is to utilize the LAPACK library, specifically the subroutines ending in GELS or GELSS, which implement QR factorization and Singular Value Decomposition (SVD) respectively. LAPACK is freely available and provides comprehensive documentation for implementation.

PREREQUISITES
  • Understanding of linear algebra concepts, particularly linear systems and least squares solutions.
  • Familiarity with Fortran programming language.
  • Knowledge of LAPACK library and its functionalities.
  • Basic understanding of matrix conditioning and numerical stability.
NEXT STEPS
  • Explore LAPACK documentation for detailed usage of GELS and GELSS subroutines.
  • Learn about QR factorization and its application in solving linear systems.
  • Study Singular Value Decomposition (SVD) and its advantages in numerical analysis.
  • Investigate other numerical libraries that complement LAPACK for enhanced performance.
USEFUL FOR

Researchers, engineers, and developers working with numerical methods, particularly those involved in solving linear systems and optimizing algorithms in Fortran.

passionfly
Messages
1
Reaction score
0
Dear all:

For a standard linear system, y(n*1)=A(n*n)x(n*1)

If y is exact and A is well-conditioned, it is easy to calculate x.

However, if y has some disturbances or some errors, at the same time, A matrix is ill-conditioned. It is difficult to accurately obtain vector x. Alternatively, we can measure more components of y (becomes m*1, where m>n) and use the least square method to calculate the approximate x vector.

It is a common problem so I guess there should be some ready-to-use Fortran codes. Anybody knows where can I find this algorithms or codes? Any advice or suggestion is welcomed!

Thank you very much and with best wishes,
Thomas
 
Physics news on Phys.org


LAPACK is the standard Fortran package to do this. The subroutines you will want end in GELS or GELSS (SGELS is single precision real; DGELS is double precision real, CGELS is single complex, ZGELS is double complex) . LAPACK is free - google will find the package and all the documentation you should need.

_GELS uses QR factorization, I believe. _GELSS uses SVD.

Good luck.

jason
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K