Introduction to Game Programming with C++ (Wordware Game Developers Library)

2.5 Linear Equations

One of the most characteristic features of algebra is equations.An equation is a statement of equality with at least one unknown variable. Consider the following equation:

Here it is stated that x+5is equal to 10; in other words, x + 5 and 10 are the same. The variable x is unknown, but we know that x is a number that when added to 5 will equal 10. Common knowledge can already tell us what this number is, but equations are rarely so simple. The aim is to rewrite the equation so that x is the only value on the left side of the equal sign, and the right side will contain an expression equal to x. In short, we want to solve the equation by finding the value of the variable x. In this case we know x = 5 because 5 + 5 = 10.

2.5.1 Rearranging Equations

The aim of an equation is to solve the unknown variable. Simple deduction has so far led to the answer in the simple case of x + 5 = 10, but there needs to be a more systematic method for solving more complicated examples. In the case of x + 5 = 10, we know that x = 5. The reason we know this is because 10 − 5 gives us a number that when added to 5 will equal 10. Therefore:

Our answer can be tested by substituting 5 for x, as follows:

Another example:

(x is some number that when multiplied by 2 will equal 10. We also know that 10/2 gives a quotient that when multiplied by 2 will equal 10.) So:

Again, this can be tested by substituting x:

2.5.2 Balancing Equations

In each of the equations presented in the previous section it can be seen that to determine the value for x, every number except x was moved to the right side of the equal sign, each of the numbers' signs was changed, and finally, x was isolated on the left side and both sides were still equal. This is the process all linear equations follow. Consider the following equation:

The first term has two factors: 2 and x. The second term is 2. When these terms are added together their sum is equal to 10. So, x multiplied by 2 and then added to 2 is equal to 10. In order to solve this equation, x should be isolated on the left side. To do this, the following steps are performed:

  1. The term 2 shall be the first to be moved to the right side. To do this, the equation needs to be balanced. 2 should be subtracted from the left side, giving us 0. Whatever we do to the left, we must do to the right. So 2 must also be subtracted from 10. The equation now looks like this:

    • 2x = 10 − 2

    • 2x = 8

  2. Next, to isolate x, the factor 2 needs to be moved to the right side. To eliminate it from the left, we must divide 2x by 2, which leaves x on its own. We must perform the same operation to the other side, and so 8 must be divided by 2. The equation has now been solved and looks as follows:

    • x = 8 / 2

    • x = 4

    This can be tested by substituting x:

    • (4 × 2) + 2 = 10

    • 8 + 2 = 10 (correct)

2.5.3 Balancing Methods

To summarize the methods for solving equations as demonstrated in the previous section, it can be stated that:

2.5.4 Simplification

Often it is helpful to simplify or reduce equations before solving them. Some guidelines follow.

Категории