Mathematics for Machine Learning - Day 4

Pour Terra11 July, 2024

Particular and General Solutions

Particular and General Solutions

Ever wonder, if there's an equation with two or more variables that aren't known and there's not enough information to use basic elimination method? Fear not, there's a solution.

Also, this topic will only discuss on depth regarding particular and general solutions as I found that it takes me even more than an hour to really understand this and I find it very fascinating :D

Particular Solutions

When a system has more than one solution, it's called a particular/special solution. One of the solution is if there are columns with only ones and zeros, the position of ones are unique in rows and columns, and ones are contained in all the rows.

Example:

Ax=BAx = B (10804 012012 00417)(x1 x2 x3 x4 x5)=(42 8 12)\begin{pmatrix} 1 & 0 & 8 & 0 & -4 \\\ 0 & 1 & 2 & 0 & -12 \\\ 0 & 0 & 4 & 1 & 7 \end{pmatrix} \begin{pmatrix} x_1 \\\ x_2 \\\ x_3 \\\ x_4 \\\ x_5 \end{pmatrix} = \begin{pmatrix} 42 \\\ 8 \\\ 12 \end{pmatrix}

Now, you might find this to be impossible to solve, but let's break it down each matrix at a time.

Take a look at matrix A:
A=(10804 012012 00417)A = \begin{pmatrix} 1 & 0 & 8 & 0 & -4 \\\ 0 & 1 & 2 & 0 & -12 \\\ 0 & 0 & 4 & 1 & 7 \end{pmatrix}

you'll find that the 1st, 2nd, and 4th column if isolated becomes an identity matrix or as I've stated before, a unique ones in all rows and zeros.

A(Reordered)=(10084 010212 00147)A(Reordered) = \begin{pmatrix} 1 & 0 & 0 & 8 & -4 \\\ 0 & 1 & 0 & 2 & -12 \\\ 0 & 0 & 1 & 4 & 7 \end{pmatrix}
While B can become be decoupled to each row:
(42 8 12)=42(1 0 0)+8(0 1 0)+12(0 0 1)\begin{pmatrix} 42 \\\ 8 \\\ 12 \end{pmatrix} = 42 \begin{pmatrix} 1 \\\ 0 \\\ 0 \end{pmatrix} + 8 \begin{pmatrix} 0 \\\ 1 \\\ 0 \end{pmatrix} + 12 \begin{pmatrix} 0 \\\ 0 \\\ 1 \end{pmatrix}
Meaning:

If we ignore the 3rd and 5th column entirely, we can find the particular solution!

(10804 012012 00417)(42 8 0 12 0)=(42 8 12)\begin{pmatrix} 1 & 0 & 8 & 0 & -4 \\\ 0 & 1 & 2 & 0 & -12 \\\ 0 & 0 & 4 & 1 & 7 \end{pmatrix} \begin{pmatrix} 42 \\\ 8 \\\ 0 \\\ 12 \\\ 0 \end{pmatrix} = \begin{pmatrix} 42 \\\ 8 \\\ 12 \end{pmatrix} (42+0+0+0+0 0+8+0+0+0 0+0+0+12+0)=(42 8 12)\begin{pmatrix} 42 + 0 + 0 + 0 + 0 \\\ 0 + 8 + 0 + 0 + 0 \\\ 0 + 0 + 0 + 12 + 0 \end{pmatrix} = \begin{pmatrix} 42 \\\ 8 \\\ 12 \end{pmatrix}

Congratulations! You've found the particular solution!

(x1 x2 x3 x4 x5)=(42 8 0 12 0)\therefore \begin{pmatrix} x_1 \\\ x_2 \\\ x_3 \\\ x_4 \\\ x_5 \end{pmatrix} = \begin{pmatrix} 42 \\\ 8 \\\ 0 \\\ 12 \\\ 0 \end{pmatrix}

General Solutions

Now this is where it took me an hour to understand what they were saying, so let's dive into it.

General solutions are basically adding in 0 to the equation. Instead of

Ax=BAx = B

We'll be adding in 0 to the first section based on the amount of non-identity matrix related columns (In our case it's two, the 3rd and 5th column)

Ax+λ10+λ20=BA x + \lambda_1 \cdot 0 + \lambda_2 \cdot 0 = B

The lambda is used because since it's multiplied by 0, any scaler added will still remain zero, so it covers all values added to it.

First General Solution (3rd Row)

(8 2 4)\begin{pmatrix} 8 \\\ 2 \\\ 4 \end{pmatrix}

Using the same decouple method as before:

(8 2 4)=8(1 0 0)+2(0 1 0)+4(0 0 1)\begin{pmatrix} 8 \\\ 2 \\\ 4 \end{pmatrix} = 8 \begin{pmatrix} 1 \\\ 0 \\\ 0 \end{pmatrix} + 2 \begin{pmatrix} 0 \\\ 1 \\\ 0 \end{pmatrix} + 4 \begin{pmatrix} 0 \\\ 0 \\\ 1 \end{pmatrix}

You'll remember that this decouple when added to x in the order of the identity matrix will become the answer. Meaning:

If (x1 x2 x3 x4 x5)=(8 2 0 4 0), then B=(8 2 4)\text{If } \begin{pmatrix} x_1 \\\ x_2 \\\ x_3 \\\ x_4 \\\ x_5 \end{pmatrix} = \begin{pmatrix} 8 \\\ 2 \\\ 0 \\\ 4 \\\ 0 \end{pmatrix} \text{, then } B = \begin{pmatrix} 8 \\\ 2 \\\ 4 \end{pmatrix}

So how do I make it zero?

Easy! the column that's associated to the matrix (In our case is the 3rd) we make it -1.

(x1 x2 x3 x4 x5)=(8 2 1 4 0)\begin{pmatrix} x_1 \\\ x_2 \\\ x_3 \\\ x_4 \\\ x_5 \end{pmatrix} = \begin{pmatrix} 8 \\\ 2 \\\ -1 \\\ 4 \\\ 0 \end{pmatrix}

Here's the proof

(10804 012012 00417)(8 2 1 4 0)\begin{pmatrix} 1 & 0 & 8 & 0 & -4 \\\ 0 & 1 & 2 & 0 & -12 \\\ 0 & 0 & 4 & 1 & 7 \end{pmatrix} \begin{pmatrix} 8 \\\ 2 \\\ -1 \\\ 4 \\\ 0 \end{pmatrix} (8+08+0+0 0+22+0+0 0+04+4+0)=(0 0 0)\begin{pmatrix} 8 + 0 - 8 + 0 + 0 \\\ 0 + 2 - 2 + 0 + 0 \\\ 0 + 0 - 4 + 4 + 0 \end{pmatrix} = \begin{pmatrix} 0 \\\ 0 \\\ 0 \end{pmatrix}

Now we add the first answer to our general solution!

Ax+λ1(8 2 1 4 0)+λ20=BA x + \lambda_1 \cdot \begin{pmatrix} 8 \\\ 2 \\\ -1 \\\ 4 \\\ 0 \end{pmatrix} + \lambda_2 \cdot 0 = B

Second General Solution (5th Row)

Surprize Quiz!

Now that you know how to find the equation for the general solution, try finding the second one yourself! The answer is at the bottom so you can check if you're correct or not.

(4 12 7)\begin{pmatrix} -4 \\\ -12 \\\ 7 \end{pmatrix}

The full equation.

We've found the particular solutions that's needed to create the general solution!

For clarity, let's discuss what we did:

  1. Find the particular solution to Ax = B
  2. Find all the solutions to Ax = 0
  3. Add steps one and two together

With these steps finished, congratulations! you've become familiar with particular and general solutions. From here on out, you know that there are cases where large unknown variables with little equations can be solved with the right conditions.

The general solution

{xR5x=(42 8 0 12 0)+λ1(8 2 1 4 0)+λ2(4 12 0 7 1),  λ1,λ2R}\left\{ x \in \mathbb{R}^5 \mid x = \begin{pmatrix} 42 \\\ 8 \\\ 0 \\\ 12 \\\ 0 \end{pmatrix} + \lambda_1 \begin{pmatrix} 8 \\\ 2 \\\ -1 \\\ 4 \\\ 0 \end{pmatrix} + \lambda_2 \begin{pmatrix} -4 \\\ -12 \\\ 0 \\\ 7 \\\ -1 \end{pmatrix}, \; \lambda_1, \lambda_2 \in \mathbb{R} \right\}

P.S. Hope you got the answer right!


Acknowledgement

I can't overstate this: I'm truly grateful for this book being open-sourced for everyone. Many people will be able to learn and understand machine learning on a fundamental level. Whether changing careers, demystifying AI, or just learning in general, this book offers immense value even for fledgling composer such as myself. So, Marc Peter Deisenroth, A. Aldo Faisal, and Cheng Soon Ong, thank you for this book.

Source: Deisenroth, M. P., Faisal, A. A., & Ong, C. S. (2020). Mathematics for Machine Learning. Cambridge: Cambridge University Press. https://mml-book.com

Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA Made with TERRA