- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

# Evaluate a Chebyshev series at points x broadcast over the columns of the coefficient in Python

To evaluate a Chebyshev series at points x, use the chebyshev.chebval(() method in Python Numpy. The 1st parameter, x, if x is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, x or its elements must support addition and multiplication with themselves and with the elements of c.

The 2nd parameter, C, an array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If c is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the coefficients may be thought of as stored in the columns of c.

The 3rd parameter, tensor, if True, the shape of the coefficient array is extended with ones on the right, one for each dimension of x. Scalars have dimension 0 for this action. The result is that every column of coefficients in c is evaluated for every element of x. If False, x is broadcast over the columns of c for the evaluation. This keyword is useful when c is multidimensional. The default value is True.

## Steps

At first, import the required library −

import numpy as np from numpy.polynomial import chebyshev as C

Create a multidimensional array of coefficients −

c = np.arange(6).reshape(3,2)

Display the array −

print("Our Array...\n",c)

Check the Dimensions −

print("\nDimensions of our Array...\n",c.ndim)

Get the Datatype −

print("\nDatatype of our Array object...\n",c.dtype)

Get the Shape −

print("\nShape of our Array object...\n",c.shape)

To evaluate a Chebyshev series at points x, use the chebyshev.chebval(() method in Python Numpy −

print("\nResult (chebval)...\n",C.chebval([1,2],c,tensor=False))

## Example

import numpy as np from numpy.polynomial import chebyshev as C # Create a multidimensional array of coefficients c = np.arange(6).reshape(3,2) # Display the array print("Our Array...\n",c) # Check the Dimensions print("\nDimensions of our Array...\n",c.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",c.dtype) # Get the Shape print("\nShape of our Array object...\n",c.shape) # To evaluate a Chebyshev series at points x, use the chebyshev.chebval(() method in Python Numpy print("\nResult (chebval)...\n",C.chebval([1,2],c,tensor=False))

## Output

Our Array... [[0 1] [2 3] [4 5]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (3, 2) Result (chebval)... [ 6. 42.]

- Related Articles
- Evaluate a Hermite series at points x broadcast over the columns of the coefficient in Python
- Evaluate a Laguerre series at points x broadcast over the columns of the coefficient in Python
- Evaluate a Legendre series at points x broadcast over the columns of the coefficient in Python
- Evaluate a Hermite_e series at points x broadcast over the columns of the coefficient in Python
- Evaluate a polynomial at points x broadcast over the columns of the coefficient in Python
- Evaluate a Chebyshev series at points x in Python
- Evaluate a polynomial at points x and x is broadcast over the columns of r for the evaluation in Python
- Evaluate a 2-D Chebyshev series at points (x, y) with 1D array of coefficient in Python
- Evaluate a 2-D Chebyshev series at points (x, y) with 3D array of coefficient in Python
- Evaluate a Chebyshev series at points x and the shape of the coefficient array extended for each dimension of x in Python
- Evaluate a 3-D Chebyshev series at points (x, y, z) with 2D array of coefficient in Python
- Evaluate a 3-D Chebyshev series at points (x, y, z) with 4D array of coefficient in Python
- Evaluate a 2-D Chebyshev series at points (x, y) in Python
- Evaluate a 3-D Chebyshev series at points (x, y, z) in Python
- Evaluate a Hermite series at points x with multidimensional coefficient array in Python