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