Learn to Solve Single Variable Linear Equations

In keeping with my new years resolution of making this site more accessible to my nieces and nephews, I’ve added a script that generates random single variable linear equations that ask the user to solve for x. The script also has a “Compute” button that will give the answer, as well as an option to to show the step by step procedure that is used to reach this solution.

In many instances, solving single variable linear equations are a person’s first introduction into variables, or solving for unknown values. This concept, though, remains very important in our daily lives, with questions such as “how many paychecks do I need to save before I can afford to buy a new car?” or “how long will it take me to get home?”

Both of these questions can be represented by a linear equation. For example if each of my paychecks is for \$500, and the car I wish to purchase has a listed price of \$4500, then the question of “how many paychecks do I need to save before I can afford to buy a new car” can be represented by the following equation, which we would like to solve for x:

`500 x = 4500`

As a second example, suppose that out of each \$500 paycheck \$100 must go towards paying my bills. Suppose also that I have already begun saving and have an initial amount of \$1300 saved already. Then the question of “how many paychecks do I need to save before I can afford to buy a new car can be represented by the following equation, which we’d also like to solve for x:

`500 x + 1300 = 4500 - 100 x`

The goal when solving an equation of this form is to isolate the variable, which in the case of these examples, means to get the x on one side of the equals sign ( = ) by itself and some number on the other side of the equals sign. We can do this by remembering a simple rule, Whatever you do to change one side of the equation, you must make the same changes on the other side of the equation. We do this because initially if we have two things being equal, the only way that they can stay equal is if we do the same things to both these things. We decide what to do by looking at what has already been done and performing the inverse operation of that action.

 If there was initially addition of some number, we will subtract that same number. If there was initially subtraction of some number, we will add that same number. If there was initially multiplication by some number, we will divide by that same number. If there was initially division by some number, we will multiply by that same number.

While there is no rule as to what the first step should be, it is generally easiest to try to keep reducing the number of terms in the equation, while trying to place all the terms with an x on one side of the equation and all the terms without an x on the other side of the equation. For instance, in the example earlier that states

`500 x + 1300 = 4500 - 100 x`

We notice that on the left hand side (LHS), x has been multiplied by 500 and the term 1300 has been added. So as a first step, we could either divide both sides by 500 or subtract 1300 from both sides. Likewise, on the right hand side (RHS), x has been multiplied by (-100) and the number 4500 has been added to it. So we could also divide both sides by by (-100) or subtract 4500 from both sides of the equation. We could also add 100 x or 500 x to both sides of the equation.

Initially there are four terms in this equation and division (by 500 or -100) will keep the number of terms in the equation at 4, whereas subtraction of 1300 or 4500 or 500 x or (-100 x) will reduce the number of terms to three. So we choose to do one of these actions. Lets go with subtraction of 1300 from both sides of the equation.

It can now be represented by

`500 x + 1300 - 1300 = 4500 - 100 x - 1300`

This simplifies to

`500 x = 3200 - 100 x`

Again we are faced with many options regarding what to do next. However, to get all the terms with an x on one side of the equation, we can add 100 x to both sides of this equation, which then becomes

`500 x + 100 x = 3200 - 100 x + 100 x`

This simplifies to
`600 x = 3200`

Now we notice that x is being multiplied by 600. So to solve for x, we only need to divide both sides by 600 which gives us that

`x = 3200 / 600`

Relating this to fraction arithmetic and Euclid’s Algorithm, we can reduce this fraction by noticing that 3200 = 200 * 16 and 600 = 200 * 3, so 3200 / 600 can be reduced to 16 / 3.

`So x = 16 / 3`

Since we’re looking for the number of paychecks I would need to save, this needs to be a whole number. 16 / 3 is greater than 5, so 5 paychecks will not be enough. So in order to make this purchase, I would need 6 paychecks.

The script also gives the option to generate a new problem to gain more practice with these types of problems.

Learn Duality in Linear Programming

I have just completed a script to help learn about duality in linear programming.

Many real world problems can be formulated as Linear Programming problems. There are often many different ways to formulate a single problem. Some of these alternative formulations can easily be proven to be equal via simple algebra and arithmetic. For example, one person may see a problem as maximizing profit while another may see the same problem as minimizing losses. The relationship between the two alternative formulations can then be shown to be that one simply has the negative objective function value of the other.

Sometimes, though, this relationship between alternative formulations is not as easy to detect. Two alternative formulations that arise regularly in linear programming problems are a primal problem and a dual problem. The dual of a linear programming problem is the problem of finding the best bound on the objective function in terms of the constraints. This dual is formulated so that every feasible solution to the dual is a bound on the primal objective function. The Weak Duality Theorem for Linear Programming says that the optimal solution for a minimization problem is always an upper bound for its dual (which is a corresponding maximization problem). Correspondingly, the optimal solution for a maximization problem is always a lower bound for its dual. This leads to the Strong Duality Theorem for Linear Programming which says that if we can find feasible solutions to the primal and dual problems with matching objective function values, then both of these solutions must be optimal for their respective problems.

This shows an importance of duality. What my script provides is a means of formulating the dual of a given problem to help understand the concept.

The rules for constructing a dual linear program are as follows:

 Primal: Dual: The ith constraint is [<=] Variable yi is [>=] 0 The ith constraint is [>=] Variable yi is is [<=] 0 The ith constraint is = Variable yi is unbounded Variable xj is [>=] 0 The jth constraint is [>=] Variable xj is [<=] 0 The jth constraint is [<=] Variable xj is unbounded The jth constraint is =

Other Blogs that have covered this topic:
A Narrow Margin
Optimization and data mining