usingMaths.com
From Theory to Practice - Math You Can Use.







<< Previous Next >>

Solving 3x3 Simultaneous Equations in Visual Basic | Elimination Method Algorithm



Solving Simultaneous Equations in Visual Basic: A Junior Secondary Guide

Welcome to this junior secondary Visual Basic math project! In this tutorial, you'll learn how to solve simultaneous equations with three unknowns using Visual Basic. This is a great way to combine your coding skills with algebra and logic.
You'll also learn the following:

  • How to use Visual Basic to solve 3x3 simultaneous equations
  • Applying the elimination method step-by-step
  • Using LCM (Least Common Multiple) to simplify equations
  • Writing a Visual Basic class to automate the solving process
Solving equations is a key part of algebra. By coding the solution in Visual Basic, you'll not only understand the math better; you'll also build a useful tool. This project is perfect for students looking to explore Visual Basic math algorithms, or teachers seeking Visual Basic algebra exercises for the classroom.



Step-by-Step Guide to Solve Three-Variable Algebra Equations | Elimination Method Visual Basic Algorithm

Let's try to draft a Visual Basic algorithm that solves simultaneous equations with 2 unknowns, using the elimination method, with the following set of equations in consideration.
         x + 2y - z = 2; and
         3x - y + 2z = 4
         2x + 3y + 4z = 9
These steps will help the student understand both the math and the logic behind the code.

Step 1:

Using the Find LCM in Visual Basic class from the Primary Category, find the LCM of the coefficients of variable z. Multiply equations 1, 2 & 3 by the LCM of the coefficients of variable z, divided by the z coefficient of the respective equation.
         (4/-1) X (x + 2y - z = 2)
    ⇒     -4x - 8y + 4z = -8
         (4/2) X (3x - y + 2z = 4)
    ⇒     6x - 2y + 4z = 8
         (4/4) X (2x + 3y + 4z = 9)
    ⇒     2x + 3y + 4z = 9

Step 2:

Subtract the new equations obtained in Step 2; eqn (2) from eqn (1) and eqn (3) from eqn (2).
         -4x - 8y + 4z = -8
    -     6x - 2y + 4z = 8
    ⇒     -10x - 6y = -16
         6x - 2y + 4z = 8
    -     2x + 3y + 4z = 9     ⇒     4x - 5y = -1

Step 3:

Call out to our Visual Basic Code for Simultaneous Equations with 2 Unknowns module to solve for x and y.
⇒         (x, y) = (1, 1);

Step 4:

Obtain z by solving for z from any of the original equations, using the found values of x and y.
         x + 2y - z = 2
⇒         1 + 2(1) - z = 2;
⇒         -z = 2 - 3 = -1;
⇒         z = -1/-1 = 1;


Create a new VB.Net class file; Project, Add Class.
Call it Simultaneous3Unknown.vb.
Optionally, Create a new VB.Net module file; Project, Add Module.
Call it Simultaneous3UnknownModule.vb.
Type out the adjoining Visual Basic (VB.Net) codes for solving simultaneous equations with 3 unknowns.


Note: The code module for finding LCM in Visual Basic has been explained in the Primary Category.

You can instead comment out the previous VB.Net code from the main module or simply continue from where it stopped.


So! Visual Basic Fun Practice Exercise - Simultaneous Equations with 3 Unknowns

As a fun practice exercise, feel free to try out your own set of x_coefficients, y_coefficients and equals values, and see how the Visual Basic code solves the resulting 3x3 Simultaneous Equations.









<< Previous Next >>