Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

แปลงพหุนามเป็นชุด Laguerre ใน Python


ในการแปลงพหุนามเป็นอนุกรม Laguerre ให้ใช้เมธอด laguerre.poly2lag() ใน Python Numpy แปลงอาร์เรย์ที่แทนค่าสัมประสิทธิ์ของพหุนามที่เรียงลำดับจากระดับต่ำสุดไปสูงสุดเป็นอาร์เรย์ของสัมประสิทธิ์ของอนุกรม Laguerre ที่เทียบเท่ากัน โดยเรียงลำดับจาก ระดับต่ำสุดไปสูงสุด

วิธีการส่งคืนอาร์เรย์ 1-D ที่มีค่าสัมประสิทธิ์ของชุด Laguerre ที่เทียบเท่ากัน Theparameter pol เป็นอาร์เรย์ 1-D ที่มีค่าสัมประสิทธิ์พหุนาม

ขั้นตอน

ขั้นแรก นำเข้าไลบรารีที่จำเป็น -

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

สร้างอาร์เรย์โดยใช้เมธอด numpy.array() -

c = np.array([1, 2, 3, 4, 5])

แสดงอาร์เรย์ -

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

ตรวจสอบขนาด -

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

รับประเภทข้อมูล -

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

รับรูปร่าง -

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

ในการแปลงพหุนามเป็นอนุกรม Laguerre ให้ใช้เมธอด laguerre.poly2lag() ใน Python Numpy -

print("\nResult (polynomial to laguerre)...\n",L.poly2lag(c))

ตัวอย่าง

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

# Create an array using the numpy.array() method
c = np.array([1, 2, 3, 4, 5])

# 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 convert a polynomial to a Laguerre series, use the laguerre.poly2lag() method in Python Numpy
print("\nResult (polynomial to laguerre)...\n",L.poly2lag(c))

ผลลัพธ์

Our Array...
   [1 2 3 4 5]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(5,)

Result (polynomial to laguerre)...
   [ 153. -566. 798. -504. 120.]