एक लीजेंड्रे श्रृंखला उत्पन्न करने के लिए, Python में polynomial.legendre.legfromroots() विधि का उपयोग करें। Themethod गुणांक की 1-डी सरणी देता है। यदि सभी मूल वास्तविक हैं तो आउट एक वास्तविक सरणी है, यदि कुछ मूल जटिल हैं, तो परिणाम में सभी गुणांक वास्तविक होने पर भी बाहर जटिल है। पैरामीटर रूट जड़ों से युक्त अनुक्रम हैं।
कदम
सबसे पहले, आवश्यक पुस्तकालय आयात करें -
from numpy.polynomial import legendre as L
Python में polynomial.legendre.legfromroots() विधि का उपयोग करके एक लीजेंड्रे श्रृंखला उत्पन्न करें -
j = complex(0,1)
print("Result...\n",L.legfromroots((-j, j))) डेटाटाइप प्राप्त करें -
print("\nType...\n",L.legfromroots((-j, j)).dtype) आकार प्राप्त करें -
print("\nShape...\n",L.legfromroots((-j, j)).shape) उदाहरण
from numpy.polynomial import legendre as L
# To generate a Legendre series, use the polynomial.legendre.legfromroots() method in Python
j = complex(0,1)
print("Result...\n",L.legfromroots((-j, j)))
# Get the datatype
print("\nType...\n",L.legfromroots((-j, j)).dtype)
# Get the shape
print("\nShape...\n",L.legfromroots((-j, j)).shape) आउटपुट
Result... [1.33333333+0.j 0. +0.j 0.66666667+0.j] Type... complex128 Shape... (3,)