Skip to content

Commit 7a3aab2

Browse files
committed
blog: gaussian elimination
1 parent a702268 commit 7a3aab2

File tree

4 files changed

+228
-33
lines changed

4 files changed

+228
-33
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
When you hear "linear algebra," your mind might jump to complex math, but at its heart lies a powerful tool called Gaussian Elimination. Far from being just a theoretical concept, this method is a workhorse in various fields of computer engineering, helping us solve systems of linear equations efficiently. In simple terms, it's a systematic way to solve multiple equations with multiple unknowns.
2+
3+
## What is Gaussian Elimination? (The Simple Explanation)
4+
5+
Imagine you have a few simple equations:
6+
Equation 1: `x + y = 5`
7+
Equation 2: `x - y = 1`
8+
9+
You can probably solve this in your head or by simple substitution. Gaussian elimination provides a step-by-step, mechanical way to solve this, even when you have hundreds or thousands of equations and variables.
10+
11+
The core idea is to transform a system of equations into an "echelon form" using three basic operations:
12+
1. **Swapping rows**: Change the order of equations.
13+
2. **Multiplying a row by a non-zero number**: Scale an equation.
14+
3. **Adding a multiple of one row to another row**: Combine equations.
15+
16+
These operations don't change the solution of the system. By applying them strategically, you eliminate variables one by one until you have a very simple system that can be solved by "back-substitution" (solving the last equation first, then plugging its answer into the second-to-last, and so on).
17+
18+
## How it Works (A Quick Visual)
19+
20+
Let's represent our equations in a matrix format (an "augmented matrix"):
21+
22+
```
23+
[ 1 1 | 5 ]
24+
[ 1 -1 | 1 ]
25+
```
26+
27+
**Step 1: Get a leading 1 in the first row, first column.** (Already done here!)
28+
29+
**Step 2: Make all entries below the leading 1 in the first column zero.**
30+
Subtract Row 1 from Row 2: `R2 = R2 - R1`
31+
32+
```
33+
[ 1 1 | 5 ]
34+
[ 0 -2 | -4 ]
35+
```
36+
37+
**Step 3: Get a leading 1 in the second row, second column.**
38+
Divide Row 2 by -2: `R2 = R2 / -2`
39+
40+
```
41+
[ 1 1 | 5 ]
42+
[ 0 1 | 2 ]
43+
```
44+
45+
Now the matrix is in row echelon form! We can translate it back to equations:
46+
Equation 1: `x + y = 5`
47+
Equation 2: `y = 2`
48+
49+
**Step 4: Back-substitution.**
50+
From Equation 2, we know `y = 2`. Substitute `y=2` into Equation 1:
51+
`x + 2 = 5`
52+
`x = 3`
53+
54+
So, `x = 3` and `y = 2`. This systematic process is what makes Gaussian Elimination so powerful for computers.
55+
56+
## Usages in Computer Engineering
57+
58+
Gaussian Elimination might seem like abstract math, but its ability to efficiently solve linear systems is fundamental to many computer engineering applications:
59+
60+
### 1. Computer Graphics
61+
* **3D Transformations**: When you move, rotate, or scale objects in 3D space, you're performing linear transformations. Combining these transformations, especially finding inverse transformations, often boils down to solving linear systems.
62+
* **Ray Tracing**: Determining intersections between rays and complex 3D objects (like planes or curved surfaces) can involve solving systems of equations.
63+
* **Lighting and Shading**: Calculating how light interacts with surfaces (e.g., diffuse, specular components) can also lead to linear systems.
64+
65+
### 2. Machine Learning and Data Science
66+
* **Linear Regression**: Finding the "best fit" line or plane for data points is a classic problem that can be solved by setting up and solving a system of linear equations (normal equations).
67+
* **Solving Optimization Problems**: Many optimization algorithms (e.g., in deep learning) involve finding solutions to systems of equations to minimize error functions.
68+
69+
### 3. Robotics and Control Systems
70+
* **Kinematics**: Determining the position and orientation of robot parts based on joint angles (forward kinematics) or finding joint angles to reach a desired position (inverse kinematics) frequently involves solving linear systems.
71+
* **Path Planning**: Calculating trajectories for robots to move from one point to another while avoiding obstacles can be formulated using linear equations.
72+
73+
### 4. Circuit Analysis
74+
* **Kirchhoff's Laws**: In electrical engineering, applying Kirchhoff's voltage and current laws to a circuit often results in a system of linear equations that need to be solved to find unknown currents or voltages.
75+
76+
### 5. Network Flow Problems
77+
* **Routing Algorithms**: In computer networks, optimizing data flow, finding shortest paths, or allocating bandwidth can be modeled as systems of linear equations or inequalities, which are then solved using techniques related to Gaussian elimination.
78+
79+
## Conclusion
80+
81+
Gaussian Elimination provides a robust and algorithmic approach to a problem that appears everywhere in computing: solving linear systems. From rendering realistic 3D graphics to teaching machines to learn, and from controlling robots to analyzing complex electrical circuits, this mathematical workhorse underpins a vast array of technologies we use every day. Its beauty lies in its simplicity and its profound impact on making complex computational problems tractable.

public/posts/posts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
[
2+
{
3+
"slug": "gaussian-elimination",
4+
"title": "Gaussian Elimination: The Swiss Army Knife of Linear Systems in Computer Engineering",
5+
"date": "2025-11-23",
6+
"updated": "2025-11-23",
7+
"description": "An explanation of Gaussian Elimination, a fundamental technique for solving linear systems, and its broad applications in computer engineering.",
8+
"tags": ["linear-algebra", "gaussian-elimination", "computer-engineering", "math", "algorithms"],
9+
"category": "dev",
10+
"filename": "gaussian-elimination.txt",
11+
"authors": ["fezcode"],
12+
"image": "/images/defaults/maxim-ilian-x8J1g0R9B-8-unsplash.jpg"
13+
},
214
{
315
"slug": "fixing-grub",
416
"title": "Fixing GRUB Syntax Errors Caused by Grub Customizer",

public/rss.xml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,80 @@
99
<link>https://fezcode.com</link>
1010
</image>
1111
<generator>RSS for Node</generator>
12-
<lastBuildDate>Fri, 21 Nov 2025 11:24:30 GMT</lastBuildDate>
12+
<lastBuildDate>Sun, 23 Nov 2025 18:00:45 GMT</lastBuildDate>
1313
<atom:link href="https://fezcode.com/rss.xml" rel="self" type="application/rss+xml"/>
14-
<pubDate>Fri, 21 Nov 2025 11:24:29 GMT</pubDate>
14+
<pubDate>Sun, 23 Nov 2025 18:00:45 GMT</pubDate>
1515
<copyright><![CDATA[2025 Ahmed Samil Bulbul]]></copyright>
1616
<language><![CDATA[en]]></language>
1717
<managingEditor><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></managingEditor>
1818
<webMaster><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></webMaster>
1919
<ttl>60</ttl>
20+
<item>
21+
<title><![CDATA[Gaussian Elimination: The Swiss Army Knife of Linear Systems in Computer Engineering]]></title>
22+
<description><![CDATA[[object Object]]]></description>
23+
<link>https://fezcode.com/#/blog/gaussian-elimination</link>
24+
<guid isPermaLink="false">https://fezcode.com/#/blog/gaussian-elimination</guid>
25+
<dc:creator><![CDATA[Ahmed Samil Bulbul]]></dc:creator>
26+
<pubDate>Sun, 23 Nov 2025 00:00:00 GMT</pubDate>
27+
<content:encoded><![CDATA[<h1>Gaussian Elimination: The Swiss Army Knife of Linear Systems in Computer Engineering</h1>
28+
<p><a href="https://fezcode.com/#/blog/gaussian-elimination">Read more...</a></p>]]></content:encoded>
29+
</item>
30+
<item>
31+
<title><![CDATA[Fixing GRUB Syntax Errors Caused by Grub Customizer]]></title>
32+
<description><![CDATA[[object Object]]]></description>
33+
<link>https://fezcode.com/#/blog/fixing-grub</link>
34+
<guid isPermaLink="false">https://fezcode.com/#/blog/fixing-grub</guid>
35+
<dc:creator><![CDATA[Ahmed Samil Bulbul]]></dc:creator>
36+
<pubDate>Sat, 22 Nov 2025 00:00:00 GMT</pubDate>
37+
<content:encoded><![CDATA[<h1>Fixing GRUB Syntax Errors Caused by Grub Customizer</h1>
38+
<p><a href="https://fezcode.com/#/blog/fixing-grub">Read more...</a></p>]]></content:encoded>
39+
</item>
40+
<item>
41+
<title><![CDATA[4 Equals For Complete Equalness]]></title>
42+
<description><![CDATA[[object Object]]]></description>
43+
<link>https://fezcode.com/#/blog/floating-point-precision-in-javascript</link>
44+
<guid isPermaLink="false">https://fezcode.com/#/blog/floating-point-precision-in-javascript</guid>
45+
<dc:creator><![CDATA[Ahmed Samil Bulbul]]></dc:creator>
46+
<pubDate>Fri, 21 Nov 2025 00:00:00 GMT</pubDate>
47+
<content:encoded><![CDATA[<h1>Behold, A New Operator <code>====</code></h1>
48+
<h2>About</h2>
49+
<p>When <code>0.1 + 0.2</code> in JavaScript yields <code>0.30000000000000004</code>, it highlights a <strong>common aspect of computer arithmetic</strong>,
50+
not a bug. This occurs because JavaScript, like most languages, uses the <strong>IEEE 754 standard</strong> for floating-point numbers,
51+
which relies on <strong>binary (base-2) representation</strong>.</p>
52+
<p><strong>Decimal fractions</strong> like 0.1 and 0.2 <strong>cannot be perfectly represented as finite binary fractions</strong>; they become infinitely repeating.
53+
When these are stored in a <strong>finite number of bits</strong>, a <strong>tiny truncation error</strong> is introduced. This <strong>slight imprecision</strong>
54+
in each number <strong>accumulates during addition</strong>, resulting in a sum that&#39;s marginally off from the <strong>exact mathematical total</strong>.</p>
55+
<h3>Solutions</h3>
56+
<p>For scenarios requiring <strong>precise decimal arithmetic</strong> (e.g., financial applications), direct floating-point calculations
57+
can be problematic. Consider these approaches:</p>
58+
<ol>
59+
<li><strong>Rounding:</strong> Use <code>toFixed()</code> to round results to a desired decimal precision. Remember to convert the string output
60+
back to a number if needed.<pre><code class="language-javascript">parseFloat((0.1 + 0.2).toFixed(1)); // 0.3
61+
</code></pre>
62+
</li>
63+
<li><strong>Integer Arithmetic:</strong> <strong>Scale numbers to integers</strong> before calculations and then scale the final result back down.<pre><code class="language-javascript">(0.1 * 10 + 0.2 * 10) / 10; // 0.3
64+
</code></pre>
65+
</li>
66+
<li><strong>Specialized Libraries:</strong> For <strong>advanced precision</strong>, utilize libraries like <code>Big.js</code> or <code>Decimal.js</code>.</li>
67+
</ol>
68+
<p>This behavior is a <strong>fundamental consequence of binary representation in computing</strong>, not a flaw in JavaScript,
69+
and <strong>understanding it is key</strong> to handling numerical precision effectively.</p>
70+
<h2>Introducing the <code>====</code> Operator: For When <code>===</code> Just Isn&#39;t Enough</h2>
71+
<p>Sometimes, <strong>strict equality</strong> (<code>===</code>) feels like it&#39;s trying <em>too hard</em> to be precise, yet still falls short of our
72+
deepest desires for perfect, unyielding truth. For those moments, when you need to compare not just value and type,
73+
but also the very <strong>essence</strong> of existence, I propose the <strong>Quadruple Equals Operator (<code>====</code>)</strong>!</p>
74+
<p>What does <code>====</code> do? Well, it&#39;s simple:</p>
75+
<ul>
76+
<li><code>0.1 + 0.2 ==== 0.3</code> would <em>(theoretically)</em> return <code>true</code>. Because in a world where <code>====</code> exists, numbers just <em>know</em> what they&#39;re supposed to be.</li>
77+
<li><code>&quot;hello&quot; ==== &quot;hello&quot;</code> would, naturally, be <code>true</code>.</li>
78+
<li><code>[] ==== []</code> might still be <code>false</code>, because even <code>====</code> respects the <strong>existential uniqueness</strong> of array instances. But I am working on it. ¯\_(ツ)_/¯</li>
79+
<li>The <code>====</code> operator is so powerful, it can detect <strong>deep existential equality</strong>, ensuring that not only values and types match,
80+
but also their <strong>historical context</strong>, their <strong>developer&#39;s intent</strong>, and their <strong>cosmic vibrational frequency</strong>.</li>
81+
</ul>
82+
<p>Alas, <code>====</code> is a mere dream, a <strong>mythical beast</strong> in the JavaScript ecosystem, born from the frustration of floating-point arithmetic.
83+
For now, we&#39;ll have to stick to our practical solutions. But one can dream of a world where <code>0.1 + 0.2 ==== 0.3</code> just <em>makes sense</em>.</p>
84+
<p><a href="https://fezcode.com/#/blog/floating-point-precision-in-javascript">Read more...</a></p>]]></content:encoded>
85+
</item>
2086
<item>
2187
<title><![CDATA[Kaprekar's Routine: A Curious Number Game]]></title>
2288
<description><![CDATA[[object Object]]]></description>

public/sitemap.xml

Lines changed: 67 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,76 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://fezcode.com/</loc>
5-
<lastmod>2025-11-21T11:24:31.012Z</lastmod>
5+
<lastmod>2025-11-23T18:00:45.737Z</lastmod>
66
<changefreq>monthly</changefreq>
77
<priority>1.0</priority>
88
</url>
99
<url>
1010
<loc>https://fezcode.com/about</loc>
11-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
11+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
1212
<changefreq>monthly</changefreq>
1313
<priority>0.8</priority>
1414
</url>
1515
<url>
1616
<loc>https://fezcode.com/blog</loc>
17-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
17+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
1818
<changefreq>monthly</changefreq>
1919
<priority>0.8</priority>
2020
</url>
2121
<url>
2222
<loc>https://fezcode.com/projects</loc>
23-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
23+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
2424
<changefreq>monthly</changefreq>
2525
<priority>0.8</priority>
2626
</url>
2727
<url>
2828
<loc>https://fezcode.com/logs</loc>
29-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
29+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
3030
<changefreq>monthly</changefreq>
3131
<priority>0.8</priority>
3232
</url>
3333
<url>
3434
<loc>https://fezcode.com/stories</loc>
35-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
35+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
3636
<changefreq>monthly</changefreq>
3737
<priority>0.8</priority>
3838
</url>
3939
<url>
4040
<loc>https://fezcode.com/settings</loc>
41-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
41+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
4242
<changefreq>monthly</changefreq>
4343
<priority>0.8</priority>
4444
</url>
4545
<url>
4646
<loc>https://fezcode.com/apps</loc>
47-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
47+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
4848
<changefreq>monthly</changefreq>
4949
<priority>0.8</priority>
5050
</url>
5151
<url>
5252
<loc>https://fezcode.com/stories/lore</loc>
53-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
53+
<lastmod>2025-11-23T18:00:45.738Z</lastmod>
5454
<changefreq>monthly</changefreq>
5555
<priority>0.8</priority>
5656
</url>
57+
<url>
58+
<loc>https://fezcode.com/#/blog/gaussian-elimination</loc>
59+
<lastmod>2025-11-23T00:00:00.000Z</lastmod>
60+
<changefreq>weekly</changefreq>
61+
<priority>0.7</priority>
62+
</url>
63+
<url>
64+
<loc>https://fezcode.com/#/blog/fixing-grub</loc>
65+
<lastmod>2025-11-22T00:00:00.000Z</lastmod>
66+
<changefreq>weekly</changefreq>
67+
<priority>0.7</priority>
68+
</url>
69+
<url>
70+
<loc>https://fezcode.com/#/blog/floating-point-precision-in-javascript</loc>
71+
<lastmod>2025-11-21T00:00:00.000Z</lastmod>
72+
<changefreq>weekly</changefreq>
73+
<priority>0.7</priority>
74+
</url>
5775
<url>
5876
<loc>https://fezcode.com/#/blog/kaprekars-routine</loc>
5977
<lastmod>2025-11-18T00:00:00.000Z</lastmod>
@@ -396,6 +414,18 @@
396414
<changefreq>monthly</changefreq>
397415
<priority>0.7</priority>
398416
</url>
417+
<url>
418+
<loc>https://fezcode.com/#/logs/iloveimg</loc>
419+
<lastmod>2025-11-23T00:00:00.000Z</lastmod>
420+
<changefreq>weekly</changefreq>
421+
<priority>0.7</priority>
422+
</url>
423+
<url>
424+
<loc>https://fezcode.com/#/logs/accent-oracle</loc>
425+
<lastmod>2025-11-21T00:00:00.000Z</lastmod>
426+
<changefreq>weekly</changefreq>
427+
<priority>0.7</priority>
428+
</url>
399429
<url>
400430
<loc>https://fezcode.com/#/logs/maxs-choice-duty-vs-passion</loc>
401431
<lastmod>2025-11-19T00:00:00.000Z</lastmod>
@@ -524,73 +554,79 @@
524554
</url>
525555
<url>
526556
<loc>https://fezcode.com/#/stories/books/1</loc>
527-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
557+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
528558
<changefreq>monthly</changefreq>
529559
<priority>0.6</priority>
530560
</url>
531561
<url>
532562
<loc>https://fezcode.com/#/stories/books/1/pages/1</loc>
533-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
534-
<changefreq>weekly</changefreq>
535-
<priority>0.5</priority>
536-
</url>
537-
<url>
538-
<loc>https://fezcode.com/#/stories/books/1/pages/2</loc>
539-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
563+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
540564
<changefreq>weekly</changefreq>
541565
<priority>0.5</priority>
542566
</url>
543567
<url>
544568
<loc>https://fezcode.com/#/stories/books/2</loc>
545-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
569+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
546570
<changefreq>monthly</changefreq>
547571
<priority>0.6</priority>
548572
</url>
549573
<url>
550574
<loc>https://fezcode.com/#/stories/books/2/pages/1</loc>
551-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
552-
<changefreq>weekly</changefreq>
553-
<priority>0.5</priority>
554-
</url>
555-
<url>
556-
<loc>https://fezcode.com/#/stories/books/2/pages/2</loc>
557-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
575+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
558576
<changefreq>weekly</changefreq>
559577
<priority>0.5</priority>
560578
</url>
561579
<url>
562580
<loc>https://fezcode.com/#/stories/books/3</loc>
563-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
581+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
564582
<changefreq>monthly</changefreq>
565583
<priority>0.6</priority>
566584
</url>
567585
<url>
568586
<loc>https://fezcode.com/#/stories/books/3/pages/1</loc>
569-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
587+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
570588
<changefreq>weekly</changefreq>
571589
<priority>0.5</priority>
572590
</url>
573591
<url>
574592
<loc>https://fezcode.com/#/stories/books/3/pages/2</loc>
575-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
593+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
576594
<changefreq>weekly</changefreq>
577595
<priority>0.5</priority>
578596
</url>
579597
<url>
580598
<loc>https://fezcode.com/#/stories/books/4</loc>
581-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
599+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
582600
<changefreq>monthly</changefreq>
583601
<priority>0.6</priority>
584602
</url>
585603
<url>
586604
<loc>https://fezcode.com/#/stories/books/4/pages/1</loc>
587-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
605+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
588606
<changefreq>weekly</changefreq>
589607
<priority>0.5</priority>
590608
</url>
591609
<url>
592610
<loc>https://fezcode.com/#/stories/books/4/pages/2</loc>
593-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
611+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
612+
<changefreq>weekly</changefreq>
613+
<priority>0.5</priority>
614+
</url>
615+
<url>
616+
<loc>https://fezcode.com/#/stories/books/5</loc>
617+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
618+
<changefreq>monthly</changefreq>
619+
<priority>0.6</priority>
620+
</url>
621+
<url>
622+
<loc>https://fezcode.com/#/stories/books/5/pages/1</loc>
623+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
624+
<changefreq>weekly</changefreq>
625+
<priority>0.5</priority>
626+
</url>
627+
<url>
628+
<loc>https://fezcode.com/#/stories/books/5/pages/2</loc>
629+
<lastmod>2025-11-23T18:00:45.742Z</lastmod>
594630
<changefreq>weekly</changefreq>
595631
<priority>0.5</priority>
596632
</url>

0 commit comments

Comments
 (0)