Simple exercises have pedagogical advantages, but some disadvantages with respect to programming, because the programs may easily become too specialized. In such cases, the exercise may explicitly ask the student to divide the program into functions and make general mathematical methods available as general, reusable functions for a set of problems. This requirement can be motivated by an extended exercise where a piece of code are needed many times, typically that several methods are applied to several problems.
Especially when using Matlab, students may be too lazy to use functions when this is not explicitly required. The result is that testing becomes absent and that extensions to more complicated cases get more error-prone.
Final remark. Linear algebra is an excellent example where the traditional mathematical recipes (algorithms) taught in the standard linear algebra courses all over the world are not compatible with how linear algebra calculations are carried out in the real world. Students are drilled in computing the inverse of \( 2\times 2 \) and \( 3\times 3 \) matrices, computing determinants using co-factors, computing eigenvalues using the characteristic polynomial, and so on. In the real world, however, golden rules of linear algebra go instead as follows: