Forward and back substitutions

Is there any function in Gauss equivalent to mldivide and mrdivide in Matlab? In triangular cases I can play with ltrisol or utrisol, but it would be nice to have something for a general case to avoid matrix inversion.

Thanks!

4 Answers



1



You can use either the slash operator ('/') or olsqr to solve a system of linear equations without using the inverse. The slash operator uses an LU based solver and as you may guess, olsqr uses the QR decomposition. Neither ever computes an inverse.

x = b/A;

or

x = olsqr(b, A);

If you want to solve x*A = b, you should be able to do this:

x = (b' / A')';

aptech

1,773


0



Great help, thanks! I knew the slash operator, but not the other one.

I played with arbitrary matrices in Gauss and found the following equivalent solutions.

Assume the system Ax=b where A=PP', i.e., P=chol(A)'. Then x can be calculated in the following ways:

x=inv(A)*b=b/A=(b/P)/P'=utrisol(ltrisol(b,P),P')

Likewise, when we have xA=b, equivalent ways of calculating x are

x=b*inv(A)=(b'/A')'=((b'/P)/P')'=utrisol(ltrisol(b',P),P')'

Note that in the first case b is a column vector, while in the second case it's a row vector.

Now my question is: among the above equivalent ways which is the numerically most stable and less subject to round-off errors?



0



The solution using the inverse is the least numerically stable. Using the QR decomposition (olsqr) should be the most numerically stable. The LU based solve (using the slash operator) should be in between. Let me see if I can get someone else to comment further.

aptech

1,773


0



Thanks for the reply and I'm grateful for further clarifications. I just tried simple and small moment matrices where numerical issues were irrelevant. However, in a filter where covariance matrices are propagated, the above alternatives may lead to different solutions. Of course, smart scaling may help, but it would be nice to know more about the numerical properties of the different solutions.

Your Answer

4 Answers

1

You can use either the slash operator ('/') or olsqr to solve a system of linear equations without using the inverse. The slash operator uses an LU based solver and as you may guess, olsqr uses the QR decomposition. Neither ever computes an inverse.

x = b/A;

or

x = olsqr(b, A);

If you want to solve x*A = b, you should be able to do this:

x = (b' / A')';
0

Great help, thanks! I knew the slash operator, but not the other one.

I played with arbitrary matrices in Gauss and found the following equivalent solutions.

Assume the system Ax=b where A=PP', i.e., P=chol(A)'. Then x can be calculated in the following ways:

x=inv(A)*b=b/A=(b/P)/P'=utrisol(ltrisol(b,P),P')

Likewise, when we have xA=b, equivalent ways of calculating x are

x=b*inv(A)=(b'/A')'=((b'/P)/P')'=utrisol(ltrisol(b',P),P')'

Note that in the first case b is a column vector, while in the second case it's a row vector.

Now my question is: among the above equivalent ways which is the numerically most stable and less subject to round-off errors?

0

The solution using the inverse is the least numerically stable. Using the QR decomposition (olsqr) should be the most numerically stable. The LU based solve (using the slash operator) should be in between. Let me see if I can get someone else to comment further.

0

Thanks for the reply and I'm grateful for further clarifications. I just tried simple and small moment matrices where numerical issues were irrelevant. However, in a filter where covariance matrices are propagated, the above alternatives may lead to different solutions. Of course, smart scaling may help, but it would be nice to know more about the numerical properties of the different solutions.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.