Skip to main content

Featured Post

Servo vs. Stepper Motors: The Engineer's Guide

Figure 1: Visual comparison . Steppers (Left) are dense and simple. Servos (Right) are longer and include a visible feedback encoder housing on the rear. The Million Dollar Question: "Which Motor Do I Need?" If you are designing a CNC machine, a packaging robot, or a conveyor system, you face the same dilemma every time: Stepper or Servo? Make the wrong choice, and you face two disasters: The Stepper Trap: Your machine "loses steps" (positional error) without knowing it, scrapping parts. The Servo Trap: You spend $5,000 on a system that could have been done for $500, blowing your budget. This guide bridges the gap between mechanical requirements and electrical reality. 1. The Stepper Motor: The "Digital Ratchet" Think of a Stepper Motor like a very strong, magnetic ratchet. It divides a full rotation into equal steps (typically 200 steps per revolution, or 1.8°). Pros: Incredible Holding Torque: Ste...
Disclosure: As an Amazon Associate, I earn from qualifying purchases.

Gauss Elimination: Partial Pivoting & Zero Errors (Part 3)

Visualization of Partial Pivoting in Gauss Elimination to prevent division by zero

Figure 1: Partial Pivoting involves swapping rows to avoid zero pivots.

The "Fatal Flaw" in Basic Code

In our previous post, Gauss Elimination (Part 2), we derived the mathematical foundation of the algorithm. However, if you implement that raw math directly into code (VBA, MATLAB, or C++), your program will eventually crash.

Why? Because the basic algorithm assumes the diagonal element (the pivot) is never zero. In the real world of engineering simulations, zeros happen frequently.

The Problem: Division by Zero

Let's look at a standard solvable system of equations:

The first step of the algorithm is to normalize the first row by dividing by the coefficient of x1 (which is 5). Since 5 is not zero, this works perfectly.

But what if the equations were rearranged?
Mathematically, the order of equations doesn't matter. But computationally, it changes everything. Look at this arrangement:

Here, the coefficient of x1 is 0. The computer attempts to divide by zero, resulting in a runtime error.

The Hidden Danger: Small Numbers

Even if the number isn't zero, but is very small (e.g., 0.000001), it causes Round-off Errors. Dividing by a tiny number creates a massive result, which can cause the computer to lose precision in the remaining digits. This is known as an "Ill-conditioned system."

The Solution: Partial Pivoting

To solve this, we use a technique called Partial Pivoting. Before performing the elimination step on a column, the algorithm must:

  1. Search: Look down the current column (below the diagonal).
  2. Identify: Find the row with the largest absolute value.
  3. Swap: Switch the current row with that row.

By ensuring the largest possible number is always in the pivot position, we avoid division by zero and minimize round-off errors.

Next Part: The Final Code

Now that we understand the logic and the safety features required, we are ready to build the robust Excel VBA tool.

Continue to Part 4:
Solving System of Equations using Gauss Elimination Method (Part 4: The Final Program)

References

Comments

Never Miss a Design Guide

Follow this series and get notified when new mechanical engineering tutorials and Excel tools are published.

Follow via RSS Feed

Add to Feedly, Inoreader, or Outlook

Popular posts from this blog

Hoeken's Linkage: Kinematics and Walking Robot Design

Figure 1: Animated simulation of the Hoeken’s Linkage showing the characteristic "tear-drop" coupler curve. 🚀 New Design Guide Available Don't just read about it—build it. Check out our new tutorial: How to Design a Hoeken’s Linkage in Excel (with Free VBA Simulator) » Introduction to the Hoekens Linkage The Hoekens linkage is a specialized four-bar mechanism designed to convert rotational motion into an approximate straight-line motion. While it serves a similar purpose to other straight-line generators, its unique coupler curve—a "tear-drop" shape—makes it exceptionally useful for intermittent motion and walking machines. One of the most fascinating aspects of kinematic theory is the concept of "Cognates." The Hoekens linkage is actually a cognate linkage of the Chebyshev Straight-line Mechanism . This means that while the physical structure and link lengths differ, they can generate...

Watt Straight-Line Linkage: Analysis and Automotive Uses

Figure 1: Kinematic diagram showing the path generated by the central point of a Watt's linkage. Introduction to Watt's Linkage The Watt's linkage (also known as the parallel motion linkage) is a cornerstone in the history of mechanical engineering. It is a type of four-bar linkage originally invented by James Watt in the late 18th century to solve a critical problem in steam engine design: constraining the piston rod to move in a straight line without using high-friction guideways. Before this invention, engines used chains to connect the piston to the beam, which meant they could only pull, not push. Watt's rigid linkage allowed for double-acting engines (pushing and pulling), doubling the power output. He was immensely proud of this kinematic solution, describing it in a 1784 letter to his partner Matthew Boulton: I have got a glimpse of a method of causing a piston rod to move up and down perpendicularly by only fixing it to a piece o...

Dowel Pins & Locating Pins: The Basics of Fixture Design

          In the world of Precision Engineering , the difference between a high-quality product and a scrap part often comes down to microns. While bolts hold parts together, they are terrible at positioning them. This is where Dowel Pins and Locating Pins become essential components in industrial tooling . What is a Dowel Pin?   Dowel pins are precision-ground fasteners used to secure the relative position of two parts. They are typically machined to extremely tight tolerances (often within 0.0001 inches) and are available in materials like: Hardened Steel: For high-wear applications in CNC fixtures . Stainless Steel: For corrosion resistance in medical or food processing machinery.  Plastic (Thermoplastic): For lightweight, non-conductive, low-load alignment. The "Play" Problem: Bolts vs. Dowels   When mechanical design engineers create components, they cannot rely on bolts for alignment. Manufacturing practices for bolt ho...