在Python中评估Hermite_e数列在点x上广播的系数列

在Python中评估Hermite_e数列在点x上广播的系数列

在这篇文章中,我们将介绍如何使用NumPy在Python中对Hermite_e数列的点x广播的系数列进行评估。

示例

Input: [1 2 3 4 5]
Output: [ -3. 1077.]
解释:输入点的Hermite_e系列。

hermite_e .hermeval方法

为了评估一个多维系数数组在x点的Hermite_e数列,NumPy提供了一个名为hermite_e.hermeval()的函数。它需要两个参数x和c。而x是一个元组或列表,c是一个系数数组,并且,它在给定的输入点上返回一个Hermite_e数列。即 – 如果一个数组有[1,2,3,4,5]这样的元素,那么Hermite_e数列将是1P_0 + 2P_1 + 3P_2 + 4P_3 + 5*P_4。下面是赫米特方法的语法。

语法 : hermite_e.hermeval(x, c, tensor)

参数:

  • x:一个列表或元组
  • c:一个有序的系数数组
  • tensor: 布尔型,可选

返回:Hermite_e系列在点x的位置

示例 1:

在这个例子中,我们正在创建一个有5个元素的系数NumPy数组,并显示其形状和尺寸。之后,我们在点–[2,4]处评估Hermite_e系列。

# import the numpy module
import numpy
  
# import hermite_se
from numpy.polynomial import hermite_e
  
# create array of coefficients with 5 elements
coefficients_data = numpy.array([1, 2, 3, 4, 5])
  
# Display the coefficients
print(coefficients_data)
  
# get the shape
print(f"\nShape of an array: {coefficients_data.shape}")
  
# get the dimensions
print(f"Dimension: {coefficients_data.ndim}")
  
# Evaluate a Hermite_e series at points - [2,4]
print("\nHermite_e series", hermite_e.hermeval(
    [2, 4], coefficients_data, tensor=False))
Python

输出:

[1 2 3 4 5]

Shape of an array: (5,)
Dimension: 1

Hermite_e series [  -3. 1077.]
Python

示例 2:

在这个例子中,我们正在创建一个有5个元素的系数NumPy数组并显示其形状和尺寸。之后,我们在点-[4,1]处评估Hermite_e系列。

# import the numpy module
import numpy
  
# import hermite_se
from numpy.polynomial import hermite_e
  
# create array of coefficients with 5 elements
coefficients_data = numpy.array([1, 2, 3, 4, 5])
  
# Display the coefficients
print(coefficients_data)
  
# get the shape
print(f"\nShape of an array: {coefficients_data.shape}")
  
# get the dimensions
print(f"Dimension: {coefficients_data.ndim}")
  
# Evaluate a Hermite_e series at points - [4,1]
print("\nHermite_e series", hermite_e.hermeval(
    [4, 1], coefficients_data, tensor=False))
Python

输出:

[1 2 3 4 5]

Shape of an array: (5,)
Dimension: 1

Hermite_e series [1077.  -15.]
Python

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Numpy 多项式

登录

注册