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 (0.968)
- Fraction Arithmetic (0.214)
- The PageRank Algorithm (0.214)
- Sudoku Program Updates (0.214)
- Approximating the Set Cover Problem (0.214)

Cool script.

There’s a little error in your word problem above, though. The -100x should’ve started on the left side of the equation, not the right. As it is, the addition of that term is decreasing x, when accounting for your required costs ought to _increase_ the number of months to get to $4500.

Thanks. I made the changes. Hope you enjoy the scripts.