Legendre বহুপদীর একটি ছদ্ম Vandermonde ম্যাট্রিক্স তৈরি করতে, Python Numpy-এ thepolynomial.legvander() পদ্ধতি ব্যবহার করুন। পদ্ধতিটি ছদ্ম-ভ্যান্ডেরমন্ডেমেট্রিক্স প্রদান করে। ফিরে আসা ম্যাট্রিক্সের আকৃতি হল x.shape + (deg + 1,), যেখানে শেষ সূচকটি সংশ্লিষ্ট Legendre বহুপদীর ডিগ্রি। dtype রূপান্তরিত x এর মতই হবে।
প্যারামিটার, x পয়েন্টের একটি অ্যারে প্রদান করে। কোন উপাদান জটিল কিনা তার উপর নির্ভর করে dtype float64 বা complex128-এ রূপান্তরিত হয়। যদি x স্কেলার হয় তবে এটি একটি 1-D অ্যারেতে রূপান্তরিত হয়৷ প্যারামিটার, deg হল ফলাফলের ম্যাট্রিক্সের ডিগ্রি৷
পদক্ষেপ
প্রথমে, প্রয়োজনীয় লাইব্রেরি আমদানি করুন -
import numpy as np from numpy.polynomial import legendre as L
একটি অ্যারে তৈরি করুন -
x = np.array([0, 3.5, -1.4, 2.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) Legendre বহুপদীর একটি ছদ্ম Vandermonde ম্যাট্রিক্স তৈরি করতে, thepolynomial.legvander() পদ্ধতি ব্যবহার করুন −
print("\nResult...\n",L.legvander(x, 2)) উদাহরণ
import numpy as np
from numpy.polynomial import legendre as L
# Create an array
x = np.array([0, 3.5, -1.4, 2.5])
# Display the array
print("Our Array...\n",x)
# Check the Dimensions
print("\nDimensions of our Array...\n",x.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",x.dtype)
# Get the Shape
print("\nShape of our Array object...\n",x.shape)
# To generate a pseudo Vandermonde matrix of the Legendre polynomial, use the polynomial.legvander() method in Python Numpy
print("\nResult...\n",L.legvander(x, 2)) আউটপুট
Our Array... [ 0. 3.5 -1.4 2.5] Dimensions of our Array... 1 Datatype of our Array object... float64 Shape of our Array object... (4,) Result... [[ 1. 0. -0.5 ] [ 1. 3.5 17.875] [ 1. -1.4 2.44 ] [ 1. 2.5 8.875]]