পাইথনে legendre.legfromroots() মেথড ব্যবহার করে দেয়া রুটসহ লেজ্যান্ড্র সিরিজ জেনারেট করা যায়। এটি ১-D কোএফিশিয়েন্ট অ্যারে রিটার্ন করে। সব রুট রিয়াল হলে আউটপুট রিয়াল, অন্যথায় কমপ্লেক্স।
প্যারামিটার
roots: রুট ধারণকারী সিকোয়েন্স।
ধাপসমূহ
১. লাইব্রেরি ইম্পোর্ট
import numpy as np
from numpy.polynomial import legendre as L
২. লেজ্যান্ড্র সিরিজ জেনারেট করুন (রুট: -1, 0, 1)
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
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)
আউটপুট
Result... [ 0. -0.4 0. 0.4]
Type... float64
Shape... (4,)