Matrix Algebra and Decompositions to solve Linear Equations

Matrix Algebra to solve Linear Equations with Python

Background

Such equations can be solved by hand, however, this manual approach to solving such problems by hand can get tedious if there are multiple equations that need to be solved simultaneously. An approach to solving such problems efficiently and accurately is by using matrix algebra. Matrices enable not only to visualize the system of “n” equations clearly but also solve these equations very systematically. Therefore, usage of matrices is highly relevant for industry applications.

In this article, we will discuss a few popular techniques of applying linear algebra for solving a set of linear equations. We begin with a basic approach and then transition to the idea of matrix decomposition to solve problems. Further, we will attempt to implement the same via Python. Towards the end of this article, we will discuss an industry application where this technique may be applicable.

Problem Statement

i. With every 2 units of asset a , 1 unit of asset b and 2 units of asset c invested, the net long position should be equal to 4

ii. With every 1 unit of asset a, 3 units of asset b, and 2 units of asset c invested, the net position must be long 5 units.

iii. 6 units to be invested in asset a

Mathematically, the above problem is formulated as below:

2a + 1b + c = 4

1a + 3b + 2c = 5

1a = 6

Let’s attempt to solve the above set of equations using 3 techniques and review the results (the results must tally, because we are solving the same set problem statement only with different techniques!)

Approach 1: Basic Matrix Algebra

Approach 2: LU Decomposition

Approach 3: QR Decomposition

The original equation was Ax = B

We restate the above in the form below:

QR. x = B

Rx = Q(inverse). B (note: Q (transpose) is the same as Q(inverse))

The answer tallies with the previous 2 approaches.

Application to Asset Management

Conclusion

Another point for readers to pursue could be to explore Cholesky decomposition technique from the point of view of generation of correlated random processes that are frequently used in modelling randomness in assets.

--

--

Founder: FinQuest Institute | Ekspert Consulting; www.finquestinstitute.com; www.ekspertconsulting.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store