• Aucun résultat trouvé

Sharing calculations to understand arithmetical algorithms and parallel computing

N/A
N/A
Protected

Academic year: 2021

Partager "Sharing calculations to understand arithmetical algorithms and parallel computing"

Copied!
4
0
0

Texte intégral

(1)

Sharing calculations to understand arithmetical

algorithms and parallel computing

We present an activity which concerns arithmetical algorithms and which serves to illustrate parallel computing. The activity is suitable for high-school pupils, but also for prospective mathematics teachers.

In the activity the pupils work in group, and each pupil plays the role of a computer. The pupils have to carry out some given computations, but before they do that, they should find a way to share the workload among them. The only required material is pen and paper (and a calculator for the last exercise).

In arithmetics there are several calculations which can easily be split among several pupils. Here we present some basic examples:

1. The sum of several numbers: Suppose that four pupils have to sum 20 numbers. Then one can partition the given sum into four sums of 5 numbers each. Every pupil computes one of the partial sums. Then the partials sums are added together: two pupils add two of the partial sums each, and then one pupil computes the total sum.

For example consider the following sum:

23+4+75+18+9+33+7+12+18+5+33+17+63+4+8+52+36+5+13+2 Each of the four pupils can carry out one of the following sums:

23 + 4 + 75 + 18 + 9 = 129 33 + 7 + 12 + 18 + 5 = 75 33 + 17 + 63 + 4 + 8 = 125 52 + 36 + 5 + 13 + 2 = 108 Then two of the four pupils carry out the following two sums:

129 + 75 = 204 and 125 + 108 = 233

(2)

Finally one pupil can carry out the sum

204 + 233 = 437 So the total sum equals 437.

Notice that for this calculation we have made use of the associativity of the sum. 2. The sum of two long numbers: Suppose that four pupils have to sum two

num-bers of 20 digits. Then the digits can be partitioned into four groups of 5 con-secutive digits. Every pupil then computes the sum of two numbers of five digits (where the initial digits are allowed to be zero), namely those corresponding to the same powers of 10 in the two initially given numbers. Then the results are pasted together, taking into account that each pupil has to get five digits and eventually a carry. Starting from the digits on the right, the carry of each partial sum has to be added to the next partial sum.

For example consider the following sum: 12 345 678 900 987 654 321 + 87 654 898 780 012 312 345 100 000 577 680 999 966 666

Each of the four pupils can carry out one of the following sums: 12345 + 87654 = 99999

67890 + 89878 = 157768 9876 + 123 = 9999 54321 + 12345 = 66666

The fourth pupil has the digits 66666 and no carry; the third pupil has the digits 09999 and no carry; the second pupil has 57768 and has 1 as carry; the first pupil has initially 99999 but with the carry from the third pupil he gets 100000. Pasting the digits together in the correct order gives the result.

Here we have made use of the fact that an addition is, apart from the carry, an operation where corresponding digits are added together. This is what allowed us to decompose the sum as we did.

3. The multiplication of a long number by a short number: Suppose that four pupils have to multiply a long number by a number which has 4 digits. Each pupil can multiply the given number by one of the digits (adding an appropriate number of zeroes at the end depending on which digit is considered). Then the four partial products are added together.

For example consider the following product:

(3)

1 234 567 890

× 1232

1 520 987 640 480

The first pupil computes 1234567890 × 2 = 2469135780. The second pupil computes 1234567890 × 3 × 10 = 37037036700. The third pupil computes 1234567890 × 2 × 100 = 246913578000. Finally, the fourth pupil computes 1234567890 × 1 × 1000 = 1234567890000 . These four numbers are then added together giving the result.

Here we have made use of the fact that the standard algorithm for carrying out a multiplication amounts to do several products of a number by a single-digit number, and these products have to be added together to give the result.

4. Making a list of prime numbers: Suppose that four pupils have to write down the prime numbers up to 100. Then they can share the workload for example as follows: the first pupil checks the prime numbers up to 50, the second those be-tween 51 and 70, the third those bebe-tween 71 and 85, and the fourth those bebe-tween 86 and 100. Notice that here we have chosen number intervals with different lengths because calculations with smaller numbers are faster. Recall that a num-ber up to 100 is prime or it has a prime factor which is at most 10 (so the numnum-ber is divisible by 2,3,5, or 7).

The result of this computation is the list of the prime numbers up to 100. The first pupil finds: 2|3|5|7|11|13|17|19|23|29|31|37|41|43|47.

The second pupil finds: 53|59|61|67. The third pupil finds: 71|73|79|83. The fourth pupil finds: 89|97.

Putting these lists together gives all primes up to 100.

Here we have used the fact that searching objects inside a set can be achieved by partitioning the set and carrying out the search in each subset of the partition. 5. Checking that a number is prime: Suppose that four pupils have the list of the

prime numbers up to 100 and that they need to check whether a number with four digits is prime. This means that the number is not divisible by any prime number of the list (recall that if a number is not prime, then the smallest prime factor is at most the square root of the number, which here is at most 100). Then the prime numbers on the list can be split up into four sublists and each pupil can check the divisibility by the prime numbers in one of the sublists.

For example, suppose that one wants to see whether 4321 is prime (for this check I recommend the use of a calculator).

The first pupil can check the divisibility by 2|3|5|7|11|13|17.

(4)

The second pupil can check the divisibility by 19|23|29|31|37|41. The third pupil can check the divisibility by 43|47|53|59|61|67. The fourth pupil can check the divisibility by 71|73|79|83|89|97.

The second pupil will find that 4321 is divisible by 29 (in fact the prime factori-sation is 4321 = 29 × 149).

Here we have again used the fact that searching objects inside a set can be achieved by partitioning the set and carrying out the search in each subset of the partition. Notice that there are also calculations in arithmetic which cannot easily be split among pupils (nor among computers), for example raising 2 to some power where the exponent is a large number.

This activity can take two hours time, when combined with an explanation about what is parallel computing and what is an algorithm (this can be presented as a strategy to achieve some computation, which is subdivided into several concrete steps).

Follow-up questions can be: describing the algorithms that one has applied; general-izing the strategy for numbers of any size. Moreover, one can address the topic of computation time required by an algorithm, supposing for simplicity that each partial operation (for example, adding two digits) takes one second.

To finish up, one can amaze the pupils by saying that computing the list of primes up to 10100 would take way more time than all the time that has passed from the Big Bang up

to today, and it would be impossible to write this list anywhere because there are many more prime numbers in this list than the number of atoms in the universe!

Références

Documents relatifs

— In a series of papers, we constructed large families of normal numbers using the concatenation of the values of the largest prime factor P (n), as n runs through particular

It is expected that the result is not true with = 0 as soon as the degree of α is ≥ 3, which means that it is expected no real algebraic number of degree at least 3 is

The simplest case of the prime ideal theorem provides an asymptotic formula for the number of integer lattice points m+ni in the complex plane at a prime norm (so distance squared)

With the preceding theorem, we could easily acquire one of the conclusions of our thesis and give an estimation of the number of prime factors of

Alladi (Alladi, 1987) proved an Erd˝os–Kac theorem for integers without large prime factors... We follow closely the proofs of Propositions 2 and 3, making appropri-

Throughout this paper, we shall use the following notations: N denotes the set of the positive integers, π( x ) denotes the number of the prime numbers not exceeding x, and p i

Zhang, The abstract prime number theorem for algebraic function fields, in: B. Berndt,

We present the formalization of Dirichlet’s theorem on the infinitude of primes in arithmetic progressions, and Selberg’s elementary proof of the prime number theorem, which