• Title: Modulo

  • Series: Advent of Mathematical Symbols

  • YouTube-Title: Advent of Mathematical Symbols - Part 14 - Modulo

  • Bright video: https://youtu.be/_BADZtIFbpw

  • Dark video: https://youtu.be/amcXawDEmLc

  • Quiz: Test your knowledge

  • PDF: Download PDF version of the bright video

  • Dark-PDF: Download PDF version of the dark video

  • Print-PDF: Download printable PDF version

  • Thumbnail (bright): Download PNG

  • Thumbnail (dark): Download PNG

  • Subtitle on GitHub: aoms14_sub_eng.srt

  • Timestamps (n/a)
  • Subtitle in English

    1 00:00:00,657 –> 00:00:03,257 The mathematical symbol of today is modulo.

    2 00:00:03,471 –> 00:00:06,028 Written as mod.

    3 00:00:06,228 –> 00:00:07,076 mod.

    4 00:00:07,971 –> 00:00:13,428 This is the modulo operator which i explain here as a binary operator.

    5 00:00:14,057 –> 00:00:19,713 Which means we have a number x on the left hand side and a number n on the right hand side.

    6 00:00:20,657 –> 00:00:24,152 and this whole operation here gives us a number back.

    7 00:00:24,900 –> 00:00:32,553 Indeed often x and n are chosen as positive integers, but the whole thing also for positive real numbers.

    8 00:00:33,543 –> 00:00:40,078 Now the whole idea of this operation is that you get the remainder after you divide x by n.

    9 00:00:40,900 –> 00:00:48,429 For example if you consider (5 mod 3) you immediately see 3 only fits one times into 5.

    10 00:00:49,100 –> 00:00:52,443 So what remains, what you can’t divide is 2.

    11 00:00:53,571 –> 00:00:59,429 In other words 5 is not a multiple of 3. We have to subtract 2 to get one.

    12 00:01:00,129 –> 00:01:08,234 Therefore the next example is simpler. If you have (6 mod 3), you see this fits well. We get out 0 as the remainder.

    13 00:01:09,271 –> 00:01:15,243 So you see if we divide 6 by 3 we get out exactly 2, but we are not interested in the 2.

    14 00:01:15,343 –> 00:01:18,903 We are only interested in the remainder. Which is 0 in this case.

    15 00:01:20,029 –> 00:01:27,557 Ok then with the next example maybe lets leave the integers and now we consider (7.1 mod 3).

    16 00:01:28,729 –> 00:01:34,410 Also here we find that the 3 fits 2 times into the number on the left hand side.

    17 00:01:35,400 –> 00:01:39,541 Hence the remainder term is exactly 1.1

    18 00:01:40,800 –> 00:01:43,637 So i hope you now know how this works.

    19 00:01:44,529 –> 00:01:50,986 I like thinking of subtracting 3 so many times until something less than 3 remains.

    20 00:01:51,757 –> 00:01:54,896 and the thing that remains is exactly our result.

    21 00:01:56,114 –> 00:01:59,186 So maybe i should also explain this with an example.

    22 00:01:59,329 –> 00:02:03,142 So lets consider (9.7 mod 2.1)

    23 00:02:03,886 –> 00:02:08,812 So first lets subtract 2.1 here. So we get 7.6

    24 00:02:09,729 –> 00:02:12,921 So lets do this again and then we get 5.5

    25 00:02:14,100 –> 00:02:18,159 Of course we do it again and then we get 3.4

    26 00:02:19,386 –> 00:02:23,342 and then in the last step we finally get 1.3

    27 00:02:24,414 –> 00:02:26,798 Which is of course less than 2.1

    28 00:02:28,100 –> 00:02:30,697 Hence this is our result here.

    29 00:02:31,843 –> 00:02:38,233 So this is how you can think of this, but the important thing is always remember it’s the remainder term we want here.

    30 00:02:39,371 –> 00:02:44,456 Hence here for the definition we could simply say: this is a number r.

    31 00:02:45,443 –> 00:02:48,957 and this number lies in the interval 0 to n.

    32 00:02:49,057 –> 00:02:51,122 Where n is not included.

    33 00:02:51,900 –> 00:02:55,570 However of course the remainder term could be 0.

    34 00:02:56,629 –> 00:03:03,157 Moreover now we also know how we get this number r, because we can write x as a sum.

    35 00:03:04,157 –> 00:03:09,711 Namely it’s n times an integer, we can call q + the remainder term r.

    36 00:03:10,700 –> 00:03:17,126 So you see for our positive numbers x and n this is exactly the procedure we explained before.

    37 00:03:17,971 –> 00:03:24,320 Ok now for the end of the video i want to show you how the modulo operator is included in Python.

    38 00:03:25,300 –> 00:03:30,146 Indeed this is simple. Instead of mod we use the % sign.

    39 00:03:32,000 –> 00:03:35,714 So you see this is exactly what the modulo operator should do.

    40 00:03:36,529 –> 00:03:40,851 and of course it also works for our decimal numbers, as we had it before.

    41 00:03:43,186 –> 00:03:47,214 However as you can see what can occur are some rounding errors.

    42 00:03:48,229 –> 00:03:51,157 Ok and with this i hope i see you next time.

    43 00:03:51,514 –> 00:03:52,157 Bye!

  • Quiz Content

    Q1: What is $ 6 \mod 2$?

    A1: $0$

    A2: $1$

    A3: $2$

    A4: $5$

    A5: $6$

    Q2: What is $ \pi \mod 1$?

    A1: $0.1415926535\ldots$

    A2: $3.1415926535\ldots$

    A3: $1.1415926535\ldots$

    A4: $2.1415926535\ldots$

    A5: $0$

    Q3: How to calculate $11 \mod 5$ in Python?

    A1: $\texttt{11 % 5}$

    A2: $\texttt{11 / 5}$

    A3: $\texttt{11 // 5}$

  • Back to overview page