arrays and plotting more easily by using arrays and array computations say we want to compute points on the curve described by the function (xe- sin( px) [ for [ pthe vectorized code can look as followsimport numpy as np np linspace( + np exp(- )*np sin( *np pi*xthis code is shorter and quicker to write than the one with lists and loopsmost people find it easier to read since it is closer to the mathematicsand it runs much faster than the list version we have already mentioned the term vectorized computationsand if you follow course in scientific python you will probably be asked at some point to vectorize function or computation this usually means nothing more than to ensure that all the mathematical functions are imported from numpy rather than mathand to then perform all the operations on entire arrays rather than looping over their individual elements the vectorized code should contain no for loops written in python the mathematical functions (xand (xin the example above are perfectly valid examples of vectorized functionseven though the actual functions look identical to the scalar versions the only major exceptions to this simple recipe for vectorization are functions that include if-tests for instancein we implemented piecewise-defined mathematical functions using if-tests these functions will not work if the input argument is an arraybecause test such as if has no precise meaning if is an array there are wayshoweverto solve this problemwhich we will look into later in the plotting curves with matplotlib the motivation for introducing numpy arrays was to plot mathematical functionsand now that we have introduced all the necessary tools we are finally ready to do so let us start with simple example say we want to plot the curve (xe- sin( px)for ranging from zero to four the code can look like import matplotlib pyplot as plt import numpy as np np linspace( + np exp(- )*np sin( *np pi*