Courses / Mathematics I
Scientific Programming

Vectorised Computation and Libraries

Mathematics I 165 words Free to read

Vectorised Computation

Scientific computing rests on two pillars: vectorised computation and numerical libraries. Modern code avoids explicit element loops.

Vectorisation expresses operations on whole arrays at once. Instead of c[i] = a[i] + b[i], you write c=a+bc = a + b.

This is dramatically faster. Python loops are slow; vectorised operations dispatch to compiled C or Fortran code using CPU SIMD parallel instructions.

ApproachExecutionReadability
LoopSlow, element-by-elementVerbose, low-level
VectorFast, compiled SIMDMatches math, concise
The CPU sees six instructions, or it sees one -- watch the count

Numerical Libraries

Numerical libraries provide tested routines so you never reimplement fundamentals. They handle stability and pivoting correctly.

Library TypeCore Purpose
Array LibraryNumPy-style multidimensional data
Linear AlgebraBLAS/LAPACK solvers and transforms

Common Pitfall: Writing explicit element-by-element loops or reimplementing standard solvers. Always prefer robust library routines over reinventing the wheel.

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

11practice questions
2interactive scenes

Scientific Programming