当前位置:首页 > 编程技术 > 正文内容

在 Python 中将一个 Legendre 系列添加到另一个 Legendre 系列

yc8881年前 (2023-02-22)编程技术451

在 Python 中将一个 Legendre 系列添加到另一个 Legendre 系列

要将一个 Legendre 系列添加到另一个系列,请使用 Python 中的 polynomial.legendre.legadd() 方法 嘟嘟。该方法返回一个数组,表示其总和的勒让德系列。

返回两个勒让德系列 c1 + c2 的总和。参数是系数序列 从低阶项到最高项排序,即 [1,2,3] 表示序列 P_0 + 2*P_1 + 3*P_2。 参数 c1 和 c2 是勒让德级数系数的一维数组,从低到高排序。

步骤

首先,导入所需的库 -

import numpy as np
from numpy.polynomial import laguerre as L

创建勒让德级数系数的一维数组 −

c1 = np.array([2,3,4])
c2 = np.array([4,3,2])

显示系数数组 −

print("Array1...\n",c1)
print("\nArray2...\n",c2)

显示数据类型 −

print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)

检查两个数组的尺寸 -

print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)

检查两个数组的形状 -

print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)

要将一个 Legendre 系列添加到另一个系列,请使用 Python Numpy 中的 polynomial.legendre.legadd() 方法。该方法返回一个数组,表示其总和的勒让德级数 -

print("\nResult (sum)....\n",L.legadd(c1, c2))


import numpy as np from numpy.polynomial import legendre as L # Create 1-D arrays of Legendre series coefficients c1 = np.array([2,3,4]) c2 = np.array([4,3,2]) # Display the arrays of coefficients print("Array1...\n",c1) print("\nArray2...\n",c2) # Display the datatype print("\nArray1 datatype...\n",c1.dtype) print("\nArray2 datatype...\n",c2.dtype) # Check the Dimensions of both the arrays print("\nDimensions of Array1...\n",c1.ndim) print("\nDimensions of Array2...\n",c2.ndim) # Check the Shape of both the arrays print("\nShape of Array1...\n",c1.shape) print("\nShape of Array2...\n",c2.shape) # To add one Legendre series to another, use the polynomial.legendre.legadd() method in Python Numpy # The method returns an array representing the Legendre series of their sum. print("\nResult (sum)....\n",L.legadd(c1, c2))

输出

Array1...
   [2 3 4]

Array2...
   [4 3 2]

Array1 datatype...
int64

Array2 datatype...
int64

Dimensions of Array1...
1

Dimensions of Array2...
1

Shape of Array1...
(3,)

Shape of Array2...
(3,)

Result (sum)....
   [6. 6. 6.]


本站发布的内容若侵犯到您的权益,请邮件联系站长删除,我们将及时处理!


从您进入本站开始,已表示您已同意接受本站【免责声明】中的一切条款!


本站大部分下载资源收集于网络,不保证其完整性以及安全性,请下载后自行研究。


本站资源仅供学习和交流使用,版权归原作者所有,请勿商业运营、违法使用和传播!请在下载后24小时之内自觉删除。


若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。


本文链接:https://www.10zhan.com/biancheng/10590.html

标签: Python
分享给朋友:

“在 Python 中将一个 Legendre 系列添加到另一个 Legendre 系列” 的相关文章

【说站】Thymeleaf报错Error resolving template “XXX”

【说站】Thymeleaf报错Error resolving template “XXX”

修改了一下开源项目的目录结构访问突然报错Error resolving template “XXX”可能原因有如下三种:第一种可能:原因:在使用springboot的过程中,如果使用thymeleaf...

【说站】用一句话就可以去除宝塔面板操作上的二次验证

【说站】用一句话就可以去除宝塔面板操作上的二次验证

用过宝塔的朋友应该都会发现,现在宝塔面板有些鸡肋的功能,删除文件、删除数据库、删除站点等操作都需要做计算题!不仅加了几秒的延时等待,还无法跳过!这时候就会有朋友在想,如何去除宝塔面板的二次验证,此篇文...

【说站】Centos8.0如何配置静态IP详解及永久关闭防火墙

【说站】Centos8.0如何配置静态IP详解及永久关闭防火墙

这篇文章主要介绍了详解Centos8 配置静态IP的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来学习一下!1. 查看自己的网关地址点击虚...

【说站】电脑安装MySQL时出现starting the server失败原因及解决方案

【说站】电脑安装MySQL时出现starting the server失败原因及解决方案

今天在安装MySQL时出现starting the server失败,经过查询分析得出以下结论,记录一下操作步骤。原因分析:如果电脑是第一次安装MySQL,一般不会出现这样的报错。如下图所示。star...

【说站】C#在PDF中添加墨迹注释Ink Annotation的步骤详解

【说站】C#在PDF中添加墨迹注释Ink Annotation的步骤详解

PDF中的墨迹注释(Ink Annotation),表现为徒手涂鸦式的形状;该类型的注释,可任意指定形状顶点的位置及个数,通过指定的顶点,程序将连接各点绘制成平滑的曲线。下面,通过C#程序代码介绍如何...

【说站】Java从resources读取文件内容的方法有哪些

【说站】Java从resources读取文件内容的方法有哪些

本文主要介绍的是java读取resource目录下文件的方法,比如这是你的src目录的结构├── main│ ├── java│ │ └── ...