Skip to content

Moe’s Homepage

Knows how to provide Solution

Menu
  • Home
  • About
    • About Me
Menu

Solving System of Linear Equations

Posted on December 27, 2023January 27, 2024 by mabouali

Table of Contents

Toggle
  • The problem
  • Method 1: The hard way
  • Method 2: The easy way — solving a system of linear equations
  • Solving A System of Linear Equations
    • Condition A: Same number of rows and columns
    • Condition B: More rows than columns
    • Condition C: Less rows than columns
  • Finding Solutions when you have less equations than unknowns
  • Back to our original problem
  • Conclusion

The problem

This post is inspired by a mathematic problem posted in Mathematical Olympiads group on LinkedIn here. It is rather a simple question. Consider the image below:

The question is, find x! Of course, instead of “here it is!”, we are interested in the numeric value of x. Other than the 45 degree angle and one angle being three times the other, there is no other information provided. So we cannot assume anything about the sizes of the edges and the sides.

We are going over two methods of answering this question. One is the hard way; and the other is the easy way. We start with the hard way.

Method 1: The hard way

We can conclude that x < 45~^\circ. Why? because if x \ge 45, then the \overline{AC} would be parallel to \overline{AD} or the intersection point of it would be below the \overline{BC}. Obviously, x cannot be zero or a negative number either. However, for any other values, i.e. 0 < x <45, \overline{AC} is going to intersect \overline{AD} at some point. To get where B would be, we can draw a line parallel to \overline{DC} at A and construct an angle of size 3x and extend the lines until \overline{DC} and \overline{AB} intersect each other.

So as to answering “Find x?”, we can say that it is any value between 0 and 45 degree. It does not have a unique solution.

In the next method we will discuss an easy method to solve this problem

Method 2: The easy way — solving a system of linear equations

In this method, we are going to use the fact that the sum of interior angles within a triangle should add up to 180 degree. You can see three triangles in the above picture: \triangle ABC, \triangle ABD, and \triangle ADC. We are going to write one equation for each triangle.

    \[\begin{matrix} \triangle ABD: & 3x + y  & = & 135 \\ \triangle ADC: & x + z & = & 45 \\ \triangle ABC: & 4x + y + z & = & 180 \end{matrix}\]

We can write the above equations in a matrix form as:

    \[\underbrace{\begin{bmatrix} 3 & 1 & 0 \\ 1 & 0 & 1 \\ 4 & 1 & 1 \end{bmatrix}}_{A} \times \underbrace{\begin{bmatrix} x \\ y \\ z \end{bmatrix}}_{s} =  \underbrace{\begin{bmatrix} 135 \\ 45 \\ 180 \end{bmatrix}}_{b}\]

And as we already know, we can compute s = A^{-1}b, and get a value for x, y, and z.

But we can’t do that!!!

You cannot compute an inverse for matrix A, as its determinant is zero. In fact, if you check you would notice that if you subtract second row from the third row, you will get the first row. Interestingly, check what will remain from \triangle ABC, if you subtract \triangle ADC} from it!!! That means you do not have 3 independent equations. You only have 2. So, let’s drop one equation and reduce our system to:

    \[\underbrace{\begin{bmatrix} 3 & 1 & 0 \\ 4 & 1 & 1 \end{bmatrix}}_{A} \times \underbrace{\begin{bmatrix} x \\ y \\ z \end{bmatrix}}_{s} =  \underbrace{\begin{bmatrix} 135 \\ 180 \end{bmatrix}}_{b}\]

So now we can solve this system. But wait. Now A is a 2 \times 3 matrix. Didn’t we need a square matrix to solve the system, i.e. as many independent equations as unknowns? Well, that depends how you define solving!!! Let’s review what solving a system of linear equations means in a general form.

Solving A System of Linear Equations

Consider the system below:

    \[As=b\]

where A_{M \times N}, s_{N \times 1}, and b_{M \times 1}. This means we have M equations and N unknowns. So, let’s see how we can solve this system

Condition A: Same number of rows and columns M = N

This is what most of us are familiar with. When A is a square matrix, i.e. the same number of rows and columns, or the same number of equations as there are unknowns. In this case, if A is invertible, then you have a unique solution s = A^{-1}b.

Condition B: More rows than columns M > N

In this case, you have more equations than you have unknowns. Although you might think that this case is not that common, I have to say, it is actually more common than the case in Condition A. A lot of real world engineering and science (biology, natural, economy, data, …) problems fall under this category. The thing is that you just know it by other names. You usually refer to this case as curve-fitting or linear regression. In this case, the solution is: s = \left ( A^TA \right )^{-1}A^Tb, where A^T is the transpose matrix and assuming A^TA is invertible.

Note that in this case, there is no solution that satisfies all the equations strictly. In another word, there is no exact solution. We are in fact looking for a solution that minimizes the norm.

Condition C: Less rows than columns M < N

In this case, you have less equations than you have unknowns. In this case, there is either no solution, or if there is one, there are many. i.e. non-unique solution. Although, I prefer to say that there is a unique interval of solutions.

If you guessed that condition C doesn’t happen that often compared to other two conditions, you are right. well, sort of!!! It just means you have not yet defined the problem properly. Most business questions sort of start like this. You have more unknowns than you have equations. By working out the problem with your customer, you can put in place more constraints and understand the problem better to close the gap.

So, how do we find these solutions if they exists?

Finding Solutions when you have less equations than unknowns

In this case we decompose the solution into two parts as follows:

    \[s = s^+ + s^-\]

Where

    \[s^+ = \begin{bmatrix} x^+ \\ y^+ \\ z^+ \end{bmatrix}\]

and

    \[s^- = \begin{bmatrix} x^- \\ y^- \\ z^- \end{bmatrix}\]

We assume that:

We assume that:

    \[s^+ =A^T \alpha\]

and

    \[As^- = 0\]

You can see that s^+ belongs to the row space of A or \Re (A), and s^- belongs to the null space of A or \aleph (A).

Now substituting our decomposed solution into the original equation we have:

    \[\begin{matrix} As & = & A \left ( s^+ + s^- \right ) & & \\    & = & A \left ( A^T \alpha + s^- \right )  & & \\    & = & AA^T \alpha + As^- & & \\    & = & AA^T \alpha & = & b \end{matrix}\]

and if AA^T, which is M \times M matrix, is invertible, we can solve for \alpha as:

    \[\alpha = (AA^T)^{-1} b\]

Now substituting this back in s^+ we get:

    \[s^+ = A^T(AA^T)^{-1}b\]

Note that while s^+ is a solution to our original system of equations, however, it is not a unique solution. By adding any possible s^-, that is any element belonging to the null space of A, you get another solution. Therefore, not a unique solution.

Back to our original problem

In our problem, we have:

    \[A = \begin{bmatrix} 3 & 1 & 0 \\ 4 & 1 & 1 \end{bmatrix}\]

Therefore,

    \[AA^T = \begin{bmatrix} 10 & 13 \\ 13 & 18 \end{bmatrix}\]

and therefore,

    \[(AA^T)^{-1} = \frac{1}{11}  \begin{bmatrix} 18 & -13 \\ -13 & 10 \end{bmatrix}\]

Therefore we have:

    \[s^+ = A^T(AA^T)^{-1}b = \frac{1}{11} \begin{bmatrix} 450 \\ 135 \\ 45 \end{bmatrix}\]

So one solution is x = \frac{450}{11} \approx 40.9090.

A lot of people on the LinkedIn post (here) answered x = 22.5, which is a correct answer only if \overline{BD} = \overline{DC}. However, the original post does not make any such claim and this is only one solution out of many. You can get x = 22.5, if you set:

    \[s^- = \frac{1}{22} \begin{bmatrix} -405 \\ 1215 \\ 405 \end{bmatrix}\]

you can check that As^- = 0. Now we have:

    \[s = s^+ + s^- = \frac{1}{2} \begin{bmatrix} 45\\ 135 \\ 45 \end{bmatrix}\]

Let’s set x to a number bigger than or equal to 45 degree and see what happens. Let’s set:

    \[s^- = \frac{1}{11} \begin{bmatrix} 45 \\ -135 \\ -45 \end{bmatrix}\]

you can check that As^- = 0, and:

    \[s = s^+ + s^- = \begin{bmatrix} 45\\ 0\\ 0 \end{bmatrix}\]

clearly y and z cannot be zero or negative; hence, this is not a valid solution.

If we set:

    \[s^- = \frac{1}{11} \begin{bmatrix} 100\\ -300 \\ -100 \end{bmatrix}\]

you will get:

    \[s = s^+ + s^- = \begin{bmatrix} 50\\ -15\\ -5 \end{bmatrix}\]

This means x = 50, but again, not a valid answer, as y and z are both negative.

As a practice, find a range for x^- component of s^- that guarantees all 3 angles, i.e. x, y, and z, are positive! Hint: if you know x^- you can define the other components, i.e. y^- and z^-, very easily. Also, you don’t need to impose x < 45 at all. Once you find the range for x^-, you can find the range for x. The only thing you need to enforce is the obvious fact of x, y, z cannot be negative. In another word, once you define the system of equations that describes your problem, by playing around with it, you can gain insight into your problem.

Conclusion

We discussed two methods to answer this question. One using a hard way, the other using an easy way. I think at this moment the only lingering question is why the second method is called the easy way!!! It is for sure much more math involved.

The reason I call the second method easier is because it is a systematic or algorithmic method to answer this problem. The first method requires to understand the problem and be able to reason the conditions. Although may be not that hard for this easy problem. But the first method requires a lot of understanding of the problem and extracting a lot of information from the problem. However, using the second method, you will reach an answer as long as you follow the steps properly. It is an algorithmic method of coming up with the solution. You don’t require to analyze the problem and understand the problem as much as in the first method.

That’s why I, personally, think systematic or algorithmic methods like method two are much easier (or better say reliable) as long as you can follow the steps properly.

Search Posts

Latest Posts

  • Face The challenges Heads On
  • Miranda Warning On Social Media In The Age of AI
  • Bus-Factor
  • It works! sometimes!
  • To comment, or not to comment, that shouldn’t be even a question!

Categories

  • Fundamentals
  • Linear Algebra
  • Mathematics
  • Memories
  • opinion
  • Piecewise-Linear
  • Programming
  • Python
  • SQL
  • Stories
  • Uncategorized

Archive

  • September 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
© 2025 Moe’s Homepage | Powered by Minimalist Blog WordPress Theme