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.


4 Answers


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;


x = olsqr(b, A);

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

x = (b' / A')';

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:


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


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?


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.


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.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy