Fortran Code for Solving Linear System w/ Least Square Method

In summary, the conversation discusses the difficulty of accurately calculating vector x in a standard linear system when there are disturbances or errors in y and the A matrix is ill-conditioned. It is suggested to measure more components of y and use the least square method to calculate an approximate x vector. The use of the Fortran package LAPACK, specifically the subroutines ending in GELS or GELSS, is recommended for this task.
  • #1
passionfly
1
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
  • #2


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
 

1. What is Fortran code?

Fortran is a programming language commonly used in scientific computing, particularly for performing numerical calculations and solving mathematical equations.

2. What is a linear system?

A linear system is a set of equations where each equation is a linear combination of the variables. It can be represented in matrix form as Ax = b, where A is a matrix of coefficients, x is a vector of variables, and b is a vector of constants.

3. What is the Least Square Method?

The Least Square Method is a mathematical technique used to find the best fit line for a set of data points. It minimizes the sum of the squared differences between the actual data points and the predicted values from the line.

4. How does Fortran code solve a linear system with the Least Square Method?

The Fortran code uses a variety of algorithms to solve the linear system, including the QR decomposition method and the singular value decomposition method. These methods involve breaking down the matrix equations into smaller, more manageable parts and using iterative processes to find the solution.

5. Why is Fortran commonly used for solving linear systems with the Least Square Method?

Fortran is a highly efficient language for numerical computations, making it well-suited for solving complex mathematical problems like linear systems. It also has a long history in scientific computing and is still widely used in many industries, making it a reliable and trusted choice for solving these types of problems.

Similar threads

  • Linear and Abstract Algebra
Replies
5
Views
1K
  • Linear and Abstract Algebra
Replies
4
Views
852
  • Linear and Abstract Algebra
Replies
9
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
1K
  • Linear and Abstract Algebra
Replies
9
Views
2K
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
915
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
588
Back
Top