Question

I want to use scipy.linalg.solve_triangular() to solve a system of the form xA=b (rather than Ax=b). Is there an easy way to do this? I thought that I could maybe transpose everything before using the function but doesn't seem to be working. Any help appreciated, am a beginner in this area!

Was it helpful?

Solution

The vector x must be (1 x n); the matrix A must be (n x m); the vector b must be (1 x m).

If you take the transpose of both sides, you get:

(xA)^T = b^T

Rearranging the LHS:

(A^T)(x^T) = b^T

Now A^T is an (m x n) matrix; x is a (n x 1) vector; b is an (m x 1) vector.

If A is square and symmetric, then by definition A^T = A. No work needed.

You can solve for x^T = (A^T)^-1 (b^T) using the usual techniques.

I would not recommend computing a matrix inverse. If your matrix is square, you're better off using LU decomposition and forward-back substitution instead. It's far more stable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top