Practice question · Numerical answer
An interpreted loop processes 2 million elements per second while the vectorised version processes 500 million per second. How many seconds does the loop need for 100 million elements?
Hints
- Divide the number of elements by the rate.
- 100 million divided by 2 million per second.
Show the answer
50
Why
100/2 = 50 seconds, against 0.2 seconds for the vectorised version. A minute versus a fifth of a second on identical arithmetic is what 'orders of magnitude slower' actually means in practice.
Practise Vectorised Computation and Libraries
The app has 5 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.
More questions on Vectorised Computation and Libraries
- Monte Carlo error falls like 1/√(N) regardless of the dimension, which is why it wins in high dimensions.
- A Monte Carlo simulation run twice with different random seeds gives two different answers. Why is that a…
- Sort each code pattern by its style.
- Complete the reason vectorised code is faster.
- Monte Carlo error falls like 1/√N. To gain one more decimal digit of accuracy, what does that cost?