เพื่อคืนค่า scaled companion matrix ของอาร์เรย์ 1-D ของ係พหุนาม ให้ใช้เมธอด hermite_e.hermecompanion() ใน Python Numpy พหุนามพื้นฐานถูกปรับสเกลเพื่อให้ companion matrix เป็น symmetric เมื่อ c เป็นพหุนามพื้นฐาน Hermite_e ให้ eigenvalue estimates ที่ดีกว่า unscaled case และสำหรับพหุนามพื้นฐาน eigenvalues รับประกันว่าเป็นจริงหากใช้ numpy.linalg.eigvalsh
เมธอดคืนค่า Scaled companion matrix ขนาด (deg, deg) พารามิเตอร์ c คืออาร์เรย์ 1-D ของ係ชุด Hermite เรียงจากอันดับต่ำไปสูง
ขั้นตอน
ก่อนอื่น import ไลบรารีที่จำเป็น:
import numpy as np
from numpy.polynomial import hermite_e as H
สร้างอาร์เรย์ 1D ของ係:
c = np.array([1, 2, 3])
แสดงอาร์เรย์:
print("Our Array...\n", c)
ตรวจสอบมิติ:
print("\nDimensions of our Array...\n", c.ndim)
ดึง datatype:
print("\nDatatype of our Array object...\n", c.dtype)
ดึง shape:
print("\nShape of our Array object...\n", c.shape)
คืนค่า scaled companion matrix:
print("\nResult...\n", H.hermecompanion(c))
ตัวอย่าง
import numpy as np
from numpy.polynomial import hermite_e as H
# Create a 1D array of coefficients
c = np.array([1, 2, 3])
# 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 return the scaled companion matrix of a 1-D array of polynomial coefficients
print("\nResult...\n", H.hermecompanion(c))
ผลลัพธ์
Our Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result... [[ 0. 0.66666667] [ 1. -0.66666667]]