1 00:00:00,500 --> 00:00:03,140 ALBERT R. MEYER: Let's take a quick look at some blunders 2 00:00:03,140 --> 00:00:05,190 that people regularly make in dealing 3 00:00:05,190 --> 00:00:07,820 with asymptotic notation, in particular with big O 4 00:00:07,820 --> 00:00:11,670 notation, which tends to confuse people. 5 00:00:11,670 --> 00:00:13,580 So the most important thing to remember 6 00:00:13,580 --> 00:00:18,540 is that this notation, something equals O of something 7 00:00:18,540 --> 00:00:24,680 else-- 1/x equals O of 1, say-- is actually 8 00:00:24,680 --> 00:00:28,920 to be understood as just a not such attractive notation, 9 00:00:28,920 --> 00:00:33,254 misleading notation for a binary relation between two functions. 10 00:00:33,254 --> 00:00:34,920 This is supposed to be a function there, 11 00:00:34,920 --> 00:00:36,753 and this is supposed to be a function there. 12 00:00:36,753 --> 00:00:40,010 And this is saying that there's a relation between the growth 13 00:00:40,010 --> 00:00:41,850 rates of these two functions. 14 00:00:41,850 --> 00:00:45,860 O of f is not quantity. 15 00:00:45,860 --> 00:00:47,674 And you mustn't treat it as such. 16 00:00:47,674 --> 00:00:49,590 So, for example-- and the equality, of course, 17 00:00:49,590 --> 00:00:50,890 is not an inequality. 18 00:00:50,890 --> 00:00:53,420 Once upon a time, we tried to get the equality replaced 19 00:00:53,420 --> 00:00:55,930 by an epsilon, which makes much better sense-- 20 00:00:55,930 --> 00:00:57,960 that is, a membership symbol. 21 00:00:57,960 --> 00:01:02,970 But there was a sense that this notation was so deeply embedded 22 00:01:02,970 --> 00:01:05,459 in the mathematical culture-- multiple mathematical 23 00:01:05,459 --> 00:01:09,290 communities-- that there was no way we were going to change it. 24 00:01:09,290 --> 00:01:13,010 In particular, a confusion where you think that that equality 25 00:01:13,010 --> 00:01:15,210 sign means some kind of an equality 26 00:01:15,210 --> 00:01:17,860 is to write instead of f equals O of g, 27 00:01:17,860 --> 00:01:20,440 well, if f equals O of g by symmetry, O of g 28 00:01:20,440 --> 00:01:22,130 ought to equal f. 29 00:01:22,130 --> 00:01:23,240 Don't write that. 30 00:01:23,240 --> 00:01:25,910 The reason is that it's a recipe for confusion, 31 00:01:25,910 --> 00:01:27,380 because look at this. 32 00:01:27,380 --> 00:01:29,820 I know that x is O of x trivially, 33 00:01:29,820 --> 00:01:31,670 which would suggest that O of x is 34 00:01:31,670 --> 00:01:34,350 equal to x, if you believe in symmetry 35 00:01:34,350 --> 00:01:37,570 and you think of O of x as being quantity. 36 00:01:37,570 --> 00:01:40,210 Well, remember, though, that 2x is also 37 00:01:40,210 --> 00:01:43,500 equal to O of x by definition of O. 38 00:01:43,500 --> 00:01:46,490 So what we wind up with is combining 2x equals 39 00:01:46,490 --> 00:01:50,370 O of x with O of x equals x is I get 2x is equal to this thing, 40 00:01:50,370 --> 00:01:51,380 is equal to x. 41 00:01:51,380 --> 00:01:54,810 I conclude that 2x is equal to x, which is absurd. 42 00:01:54,810 --> 00:01:56,180 So that's nonsense. 43 00:01:56,180 --> 00:01:58,370 It's the kind of trouble that you 44 00:01:58,370 --> 00:02:01,190 can get into if you start thinking of this equality 45 00:02:01,190 --> 00:02:03,760 as meaning equality between two quantities, 46 00:02:03,760 --> 00:02:09,699 as opposed to just being a part of the name of a relation. 47 00:02:09,699 --> 00:02:12,220 Another mistake that people make is less serious 48 00:02:12,220 --> 00:02:17,370 but it's sloppy, is to think that big O 49 00:02:17,370 --> 00:02:20,020 corresponds to a lower bound, so that people will say things 50 00:02:20,020 --> 00:02:23,410 like f is at least O of n squared. 51 00:02:23,410 --> 00:02:25,330 Well, again, at least O of n squared 52 00:02:25,330 --> 00:02:29,170 is starting to treat O of n squared like a quantity. 53 00:02:29,170 --> 00:02:31,370 You could say that f is equal to O of n square, 54 00:02:31,370 --> 00:02:33,720 but that means that n squared is an upper bound 55 00:02:33,720 --> 00:02:37,240 on f to within a constant factor after a certain point. 56 00:02:37,240 --> 00:02:41,610 If you want to say intuitively that n squared is a lower 57 00:02:41,610 --> 00:02:44,980 bound on f, then all you have to do 58 00:02:44,980 --> 00:02:47,490 is say that n squared is O of f. 59 00:02:47,490 --> 00:02:52,250 And that is a proper use of O of f of getting a lower 60 00:02:52,250 --> 00:02:54,970 bound on a function, by saying that the lower bound is 61 00:02:54,970 --> 00:02:55,990 O of the function. 62 00:02:59,070 --> 00:03:01,360 Another example of the kind of nonsense 63 00:03:01,360 --> 00:03:03,270 that you see-- this is a stretch, but let's 64 00:03:03,270 --> 00:03:06,840 look at it as a reminder of things not to do. 65 00:03:06,840 --> 00:03:10,110 I'm going to prove to you that the sum from i equals 1 to n 66 00:03:10,110 --> 00:03:15,390 of i-- that is that 1 plus 2 plus 3 up to n-- is O of n. 67 00:03:15,390 --> 00:03:16,640 Now, of course, it's not. 68 00:03:16,640 --> 00:03:18,530 We know that the sum of the first n 69 00:03:18,530 --> 00:03:20,470 integers n times n plus 1 over 2, 70 00:03:20,470 --> 00:03:23,850 which is O of n squared-- theta of n squared actually. 71 00:03:23,850 --> 00:03:25,660 So I'm going to prove something false. 72 00:03:25,660 --> 00:03:27,690 Watch carefully how I do it. 73 00:03:27,690 --> 00:03:30,030 Here's the false proof. 74 00:03:30,030 --> 00:03:33,380 Let's, first of all, notice that any constant is O of 1. 75 00:03:33,380 --> 00:03:39,810 So 0 is O of 1, 1 is O of 1, 2 is O of 1, and so on. 76 00:03:39,810 --> 00:03:45,460 Any constant function is O of the constant function 1. 77 00:03:45,460 --> 00:03:47,720 OK, that's true. 78 00:03:47,720 --> 00:03:51,750 So that means that each i in this sum, i is a number, 79 00:03:51,750 --> 00:03:55,790 so that means it might be 1, it might be 2, it might be 3, 80 00:03:55,790 --> 00:03:56,640 it might be 50. 81 00:03:56,640 --> 00:03:59,080 Whatever it is, it's O of 1. 82 00:03:59,080 --> 00:04:02,255 And that means that I could think of this sum from i 83 00:04:02,255 --> 00:04:06,940 equals 1 to n as O of 1 plus O of 1 plus O of 1. 84 00:04:06,940 --> 00:04:10,200 And that's, of course, n times O of 1, which is O of n. 85 00:04:10,200 --> 00:04:12,190 Now, there's all kinds of weird arithmetic 86 00:04:12,190 --> 00:04:15,430 rules of things being used here, none of which are justified. 87 00:04:15,430 --> 00:04:17,120 But it's just a heads up. 88 00:04:17,120 --> 00:04:21,829 You do see stuff like this from inexperienced students. 89 00:04:21,829 --> 00:04:24,310 And I hope that you won't fall into this kind 90 00:04:24,310 --> 00:04:25,900 of a sloppy trap. 91 00:04:25,900 --> 00:04:28,840 O of something is not a quantity. 92 00:04:28,840 --> 00:04:31,770 It's part of the name of a relation.