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