Intro to Maths for CS: Powers and Surds Joshua Knowles School of Computer Science, University of Birmingham Term 1, 2015-16 (Slides by John Barnden)
Textbook Parts (7th Ed) Programme F.1, section on Powers and Programme F.2, section on Powers and Logarithms, ignoring logarithms FOR NOW NB: I won t be covering everything in these sections, but you should know it all NB: And there is stuff in my slides that goes beyond the textbook. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 2 / 16
Some Terminology Raising something to a power, as in the expression (a + 3) 5, is also called exponentiation. The power (5 there) is also called the exponent in the expression. It doesn t have to be a single number: it can be an expression evaluating to a number (of any sort: whole, fractional, etc.). The thing that s raised to a power is called the base a +3in the above example, We can read the above expression as a plus 3 all raised to the power 5 or a plus 3 all to the power 5 or a plus 3 all to the 5. You can omit the all is the meaning is clear. If x n = y where n is a natural number > 1, then x is the nth root of y. Special cases: n =2: square root n =3: cube root. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 3 / 16
Exponential Functions: Initial Points An exponential function of x is typically a function where x or a multiple of it appears as the exponent, and the base is a constant. We can also have a constant coefficient. E.g.: 2 x, 7 3 5x. When we say that something y rises exponentially with respect to x (e.g., prices rising as times passes) we should mean that y is an exponential function of x where the base is greater than 1. E.g. P(t) =Q 1.7 t T where P(t) is the price of a particular Picasso painting at time t and T is some particular time (year/month/day...) before t. A double exponential function of x is where the power is itself an exponential, as in 3 2x More on exponentials later they re important in Computer Science! Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 4 / 16
Polynomial Functions An polynomial function of x is a function expressed as one or more terms added or subtracted, where each term is some number (a coefficient ) times a positive-whole-number power of x, except that one of the terms can be just a number. Examples: 3x 2 3x +4.67 x 17 +7.9x 8 x 7 x 2.5x +6 13 Note that x 1 = x, Also, the polynomial can just be a constant (a single number) basically this is allowed because x 0 = 1 (though undefined when x = 0). It s conventional but not necessary to write the terms in decreasing order of the power. The highest power used is the degree of the polynomial. A constant function, considered as a polynomial, has degree zero. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 5 / 16
Exponential/Polynomial Contrast The contrast between exponential and polynomial functions is crucial in CS. For instance, an algorithm that takes exponential time in the problem size (i.e., the time taken is an exponential function of the amount of input data), or uses an amount of space that s exponential in the problem size, is likely to take far too much time or use far too much space for problems of any decent size. A polynomial might still lead to bad behaviour, but it s usually much better than an exponential (depending on the details of the functions and the problem sizes to be encountered). The lower the degree of the polynomial, the better. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 6 / 16
Rules about Powers The following set of rules is nice to adopt. The letters X, Y, f, g stand for any expressions with numerical values. 0 f =0 whenf > 0 1 f = 1 (or -1 under some circumstances see later) X 0 =1 whenx 0, undefined otherwise X 1 = X X f X g = X f +g (multiplication by adding exponents) X f /X g = X f g (division by subtracting exponents) 1/X f = X f (reciprocating by negating exponents) X 1/f =thefthroot of X, when f > 1 is a natural number (X f ) g = X fg (iteration of exponentiation by multiplying exponents) (XY ) f = X f Y f (distribution of exponentiation over multiplication) (X /Y ) f = X f /Y f (distribution of exponentiation over division) Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 7 / 16
AISDE Why Those Rules? Some of the rules have to be true in the case of whole number powers bigger than 1. But others are just convenient extensions to powers in general, leading to a simple elegant story. We must have X f X g = X f +g when f and g are positive whole numbers, because X f product involving only X, f times. is Clearly X f X g just is the product involving only X, f + g times. Similarly, when f and g are positive whole numbers, with f > g + 1, X f /X g just is the product involving X f g times. But if now f = g + 1, X f /X g = X. We have f g = 1, so it s convenient to declare that X 1 = X, so that in the above comment about division we can generalize to include the case of f = g + 1. And if f = g, thenx f /X g = 1 and f g = 0, so we can make things yet simpler by declaring that X 0 = 1. This also means we can have f and/or g be 0 in the above rule about X f X g. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 8 / 16
Why Those Rules? contd (1/X f )X f = 1, so it s convenient to say that 1/X f = X f, because this means we can say: (1/X f )X f = X f X f = X f +f = X 0 =1 if we also now allow negative powers in the multiplication-by-adding-powers rule. Similarly, it s good to use X 1/f to mean the f th root of X (when f > 1 and f is a whole number), because it fits with the rule about iterated exponentiation if we also now allow that rule to use fractions: (X 1/f ) f = X (1/f )f = X 1 = X We can now make sense of X h for any rational h, positive or negative. E.g.: X 8/5 = 1/ 5 X 8 = 1/( 5 X ) 8 = (1/ 5 X ) 8 = 5 (1/X ) 8 = ((two more: EXERCISE)) Making sense of the case of irrational h is more difficult and we will allow it but not go into it. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 9 / 16
Lack of Rules for Other Cases CAUTION: there s not much we can do in any simple, general way with (X + Y ) f (X Y ) f. or If f is a natural number, then we can multiply out, e.g. (X +Y ) 3 =(X +Y )(X +Y ) 2 =(X +Y )(X 2 +2XY +Y 2 )=X 3 +3XY 2 +3X 2 Y +Y 3 And if f is a negative whole number we can similarly do something, e.g. (X + Y ) 3 = 1/(X + Y ) 3 = 1/(X 3 +3XY 2 +3X 2 Y + Y 3 ) But there s nothing similar for fractional or irrational powers. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 10 / 16
Surd Notation Surd notation is the use of the symbols X where X is any expression with a numerical value and f is an expression whose value is natural number bigger than 1. E.g.: 2 17 17 2 5 x 3 +tanπ/3 14 When f is the expression 2 we normally omit the 2 and just write... The expression f is almost always an overt number, rather than a variable or a complex expression. E.g., you DON T normally see things like x 17 10+7 2 However, there are no limitations on what the X part looks like. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 11 / 16
Positive and Negative Roots Recall from Rules about Powers that: X 1/f = f X when f is a natural number > 1. e.g.: 243 1/5 = 5 243 = 3 When f is odd, X s value can be positive or negative or zero, and the f th root is positive or negative respectively. This is simply because if you raise a negative number to an odd power you get a negative number. ( 3) 5 = 243 so ( 243) 1/5 = 3 Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 12 / 16
Positive and Negative Roots, contd When f is even, then X s value must be non-negative (unless we introduce complex numbers not treated in this module), and we get both a positive root and a negative root. This is because if you raise either a negative or a positive number to an even power you get a positive number. E.g., 6 729 = 729 1/6 = either 3 or -3, in principle. However, normally the non-negative value is assumed to be meant. If we specifically want the negative value we would normally write, e.g. 6 729 or 729 1/6. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 13 / 16
Rules about Surds From the Rules about Powers, we immediately get things like: 1 = 1 (or can be -1 if f even) XY = X Y X /Y = X / Y 1/Y =1/ Y X g = X g/f =( f X ) g f g X = fg X X g X =( fg X ) f +g EXERCISE: Ensure you understand why all these, especially the last one, hold. Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 14 / 16
Manipulating Surd Expressions Examples of application of the above rules: 320 = 64 5 = 64 5 = 8 5. 3 1/320 = 1/ 3 320 = 1/ 3 64 5 = 1/( 3 64 3 5) = 1/(4 3 5). 81/121 = 81/ 121 = 9/11 6 343 = 3 343 = 7 6 36 = 3 36 = 3 6 1 y = y y 1 7 z = ( 7 z) 6 z Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 15 / 16
Manipulating Surd Expressions, contd ( x + 3) 3 =( x + 3) 2 x +3=(x + 3) x +3 ( 8 7) 12 =( 8 7) 8+4 =( 8 7) 8 ( 8 7) 4 =7 7 ( 8 7) 12 =7 12/8 =7 1 1 2 =7 7 1/2 =7 7 Barnden (SoCS) Intro to Maths for CS: Powers and Surds Term 1, 2014 15 16 / 16