Question: My question is how to make a vandermonde matrix. This is the definition:
In linear algebra, a Vandermonde matrix, named after Alexandre-Théophile Vandermonde, is a matrix with the terms of a geometric progression in each row, i.e., an m × n matrix

I would like to make a 4\*4 version of this.

So farI have defined values but only for one row as follows

```
a=2
n=4

for a in range(n):

    for i in range(n):
        v.append(a**i)
v = np.array(v)
print(v)

```

I dont know how to scale this. Please help!

Answer: 
Given a starting column `a` of length `m` you can create a Vandermonde matrix `v` with `n` columns `a**0` to `a**(n-1)`like so:

```
import numpy as np

m = 4
n = 4

a = range(1, m+1)
v = np.array([a]*n).T**range(n)
print(v)
#[[ 1  1  1  1]
# [ 1  2  4  8]
# [ 1  3  9 27]
# [ 1  4 16 64]]

```
As proposed by [michael szczesny](https://stackoverflow.com/users/14277722/michael-szczesny) you could use [numpy.vander](https://numpy.org/doc/stable/reference/generated/numpy.vander.html).
But this will **not** be according to the definition on [Wikipedia](https://en.wikipedia.org/wiki/Vandermonde_matrix).

```
x = np.array([1, 2, 3, 5])
N = 4
np.vander(x, N)

#array([[  1,   1,   1,   1],
#       [  8,   4,   2,   1],
#       [ 27,   9,   3,   1],
#       [125,  25,   5,   1]])

```

So, you'd have to use [numpy.fliplr](https://numpy.org/doc/stable/reference/generated/numpy.fliplr.html) aswell:

```
x = np.array([1, 2, 3, 5])
N = 4
np.fliplr(np.vander(x, N))

#array([[  1,   1,   1,   1],
#       [  1,   2,   4,   8],
#       [  1,   3,   9,  27],
#       [  1,   5,  25, 125]])

```

This could also be achieved without numpy using [nested list comprehensions](https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions):

```
x = [1, 2, 3, 5]
N = 4
[[xi**i for i in range(N)] for xi in x]

#   [[1, 1, 1, 1],
#    [1, 2, 4, 8],
#    [1, 3, 9, 27],
#    [1, 5, 25, 125]]

```