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

2.4 Algebraic Expressions

Having considered some of the rules and ideas used in algebra such as negative numbers, exponents, and properties of multiplication and division, it is time to examine some simple algebraic expressions where letters are used in place of numbers. The letters represent numbers that we do not know. Consider the following expression:

Note 

Please note that in most algebra multiplication, the cross symbol is omitted and the two factors are written side by side.

The above expression has four terms: 2a, 5a, 7a, and −9a. Terms are separated by addition and subtraction symbols. Each term has two factors; for example, 2a means 2 × a. Both 2 and a are factors. The letter a represents an unknown number, and is called a variable or literal.

2.4.1 Coefficients

In the factors 2a, 2 is said to be the coefficient of a, and a is said to be the coefficient of 2. In the factors abcd (which means a × b × c × d), the coefficient of a is bcd and the coefficient of b is acd. Therefore, a coefficient of any factor is every other factor (not including itself) in a single term.

2.4.2 Like Terms

In an algebraic expression, any two terms are said to be like terms when they have the same variable factors; in other words, they may have different actual number values but they will be multiplied by the same letters.

2.4.3 Collect Like Terms

In algebra, subtraction is seen as adding a negative number. We know that 5 + (−3) is the same as 5 − 3 (the minus sign belongs to 3; minus is the sign and 3 is the absolute value). The previous section demonstrated how like terms can be considered those with common variable factors, such as 2a and 5a. Whenever like terms are encountered, they can be added together to form a single term.

Категории