लेगेंडर बहुपद गुणांकों के 1-D ऐरे का स्केल्ड साथी मैट्रिक्स लौटाने के लिए, पायथन Numpy में legendre.legcompanion() विधि का उपयोग करें। लेगेंडर बहुपदों का सामान्य साथी मैट्रिक्स पहले से ही सममित होता है जब c एक आधार लैगुएर बहुपद होता है, इसलिए कोई स्केलिंग लागू नहीं की जाती।
(deg, deg) आयामों का स्केल्ड साथी मैट्रिक्स लौटाता है। पैरामीटर c, निम्न से उच्च डिग्री तक क्रमबद्ध लेगेंडर श्रृंखला गुणांकों का 1-D ऐरे है।
चरण
सबसे पहले, आवश्यक लाइब्रेरी आयात करें −
import numpy as np from numpy.polynomial import legendre as L
गुणांकों का 1D ऐरे बनाएं −
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)लेगेंडर बहुपद गुणांकों के 1-D ऐरे का स्केल्ड साथी मैट्रिक्स लौटाने के लिए, पायथन Numpy में legendre.legcompanion() विधि का उपयोग करें। लेगेंडर बहुपदों का सामान्य साथी मैट्रिक्स पहले से ही सममित होता है जब c एक आधार लैगुएर बहुपद होता है, इसलिए कोई स्केलिंग लागू नहीं की जाती −
print("\nResult...\n",L.legcompanion(c))उदाहरण
import numpy as np from numpy.polynomial import legendre as L # Create a 1D array of coefficients 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 return the scaled companion matrix of a 1-D array of Legendre polynomial coefficients, use the legendre.legcompanion() method in Python Numpy print("\nResult...\n",L.legcompanion(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... [[ 0. 0.57735027 0. -0.30237158] [ 0.57735027 0. 0.51639778 -0.34914862] [ 0. 0.51639778 0. 0.10141851] [ 0. 0. 0.50709255 -0.45714286]]