![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
numpy.vander Method in Python
The numpy.vander() method is used to generate a Vandermonde (Vander) matrix. A Vander matrix contains a geometric progression in each row, for example,
$$\mathrm{A =\begin{bmatrix}1 & 2 & 4 \1 & 3 & 9 \1 & 5 &25\end{bmatrix} or\: B = \begin{bmatrix}1 & 4 & 16 \1 & 6 &36 \end{bmatrix}}$$
Syntax
Its syntax is as follows −
numpy.vander(x, N=None, increasing=False)
Parameters
It accepts the following parameters −
x - This is the input array.
N - It is the number of columns in the output. By default, it is None.
Increasing - If increasing=True, then the power increases from left to right. If increasing=False, then powers are reversed.
Example 1
Let us consider the following example −
# import numpy library import numpy as np # create an array a = np.array([11, 12, 13]) print("Input Array :", a) # Vander function x = np.vander(a) print("Vander Elements:
", x)
Output
It will generate the following output −
Input Array : [11 12 13] Vander Elements: [[121 11 1] [144 12 1] [169 13 1]]
Example 2
Let us take another example −
# import numpy library import numpy as np # create an array x = np.array([4, 5, 9]) print("Input Array :", x) # vander function y = np.vander(x, increasing=True) print("Vander Elements:
", y)
Output
It will generate the following output −
Input Array : [4 5 9] Vander Elements: [[ 1 4 16] [ 1 5 25] [ 1 9 81]]
Advertisements