Skip to main content

Section 7.4 Python recap

Vandermonde matrix. The \(n\times n\;\)Vandermonde matrix of a vector \(x=[x_1,\dots,x_n]\) is the matrix
\begin{equation*} \begin{pmatrix} 1&x_1&x_1^2&\dots&x_1^n\cr 1&x_2&x_2^2&\dots&x_2^n\cr \vdots&\vdots&\vdots&\ddots&\vdots\cr 1&x_n&x_n^2&\dots&x_n^n\cr \end{pmatrix}. \end{equation*}
In Numpy, this matrix is created with the command vander(x). Notice that the matrix created by Numpy is the transpose of the one shown above.

MATLAB/Python functions. So far we defined mathematical functions with the syntax like fun = lambda x: x**2-2. Often, though, one needs to use mathematical functions with a more complicated definition, that takes several lines of code, or even just define a set of instructions that accomplishes some task and is used several times in the same code. This can be accomplished with the syntax that we show in the several examples in the code below.