Computer >> कंप्यूटर >  >> प्रोग्रामिंग >> Python

लीजेंड्रे बहुपद और x, y, z फ़्लोटिंग ऐरे ऑफ़ पॉइंट्स का एक छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करें

x, y, z नमूना बिंदुओं के साथ लीजेंड्रे बहुपद का छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करने के लिए, Python Numpy में Legendre.legvander3d() विधि का उपयोग करें। डिग्री डिग्री और नमूना बिंदुओं (x, y, z) का छद्म-वैंडरमोंड मैट्रिक्स देता है।

पैरामीटर, x, y, z बिंदु निर्देशांक के सरणियाँ हैं, सभी एक ही आकार के हैं। कोई भी तत्व जटिल है या नहीं, इस पर निर्भर करते हुए dtypes को या तो float64 या complex128 में बदल दिया जाएगा। स्केलर को 1-D सरणियों में बदल दिया जाता है। पैरामीटर, डिग्री फॉर्म की अधिकतम डिग्री की एक सूची है [x_deg, y_deg, z_deg]।

कदम

सबसे पहले, आवश्यक पुस्तकालय आयात करें -

import numpy as np
from numpy.polynomial import legendre as L

numpy.array() विधि का उपयोग करके बिंदु निर्देशांकों की सरणियाँ बनाएँ, सभी समान आकार की -

x = np.array([1.5, 2.3])
y = np.array([3.7, 4.4])
z = np.array([5.3, 6.6])

सरणियों को प्रदर्शित करें -

print("Array1...\n",x)
print("\nArray2...\n",y)
print("\nArray3...\n",z)

डेटाटाइप प्रदर्शित करें -

print("\nArray1 datatype...\n",x.dtype)
print("\nArray2 datatype...\n",y.dtype)
print("\nArray3 datatype...\n",z.dtype)

दोनों सरणियों के आयामों की जाँच करें -

print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
print("\nDimensions of Array3...\n",z.ndim)

दोनों सरणियों के आकार की जाँच करें -

print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)

x, y, z नमूना बिंदुओं के साथ लीजेंड्रे बहुपद का छद्म वेंडरमोंड मैट्रिक्स उत्पन्न करने के लिए, Python में Legendre.legvander3d() विधि का उपयोग करें -

x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))

उदाहरण

import numpy as np
from numpy.polynomial import legendre as L

# Create arrays of point coordinates, all of the same shape using the numpy.array() method
x = np.array([1.5, 2.3])
y = np.array([3.7, 4.4])
z = np.array([5.3, 6.6])

# Display the arrays
print("Array1...\n",x)
print("\nArray2...\n",y)
print("\nArray3...\n",z)

# Display the datatype
print("\nArray1 datatype...\n",x.dtype)
print("\nArray2 datatype...\n",y.dtype)
print("\nArray3 datatype...\n",z.dtype)

# Check the Dimensions of both the arrays
print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
print("\nDimensions of Array3...\n",z.ndim)

# Check the Shape of both the arrays
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)

# To generate a pseudo Vandermonde matrix of the Legendre polynomial with x, y, z sample points, use the legendre.legvander3d() method in Python Numpy
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))

आउटपुट

Array1...
   [1.5 2.3]

Array2...
[3.7 4.4]

Array3...
[5.3 6.6]

Array1 datatype...
float64

Array2 datatype...
float64

Array3 datatype...
float64

Dimensions of Array1...
1

Dimensions of Array2...
1

Dimensions of Array3...
1

Shape of Array1...
(2,)

Shape of Array2...
(2,)

Shape of Array3...
(2,)

Result...
   [[1.00000000e+00 5.30000000e+00 4.16350000e+01 3.64242500e+02
     3.34712294e+03 3.70000000e+00 1.96100000e+01 1.54049500e+02
     1.34769725e+03 1.23843549e+04 2.00350000e+01 1.06185500e+02
     8.34157225e+02 7.29759849e+03 6.70596081e+04 1.21082500e+02
     6.41737250e+02 5.04126989e+03 4.41033925e+04 4.05278013e+05
     1.50000000e+00 7.95000000e+00 6.24525000e+01 5.46363750e+02
     5.02068441e+03 5.55000000e+00 2.94150000e+01 2.31074250e+02
     2.02154588e+03 1.85765323e+04 3.00525000e+01 1.59278250e+02
     1.25123584e+03 1.09463977e+04 1.00589412e+05 1.81623750e+02
     9.62605875e+02 7.56190483e+03 6.61550888e+04 6.07917020e+05
     2.87500000e+00 1.52375000e+01 1.19700625e+02 1.04719719e+03
     9.62297845e+03 1.06375000e+01 5.63787500e+01 4.42892313e+02
     3.87462959e+03 3.56050202e+04 5.76006250e+01 3.05283313e+02
     2.39820202e+03 2.09805957e+04 1.92796373e+05 3.48112188e+02
     1.84499459e+03 1.44936509e+04 1.26797253e+05 1.16517429e+06]
    [1.00000000e+00 6.60000000e+00 6.48400000e+01 7.08840000e+02
     8.13847200e+03 4.40000000e+00 2.90400000e+01 2.85296000e+02
     3.11889600e+03 3.58092768e+04 2.85400000e+01 1.88364000e+02
     1.85053360e+03 2.02302936e+04 2.32271991e+05 2.06360000e+02
     1.36197600e+03 1.33803824e+04 1.46276222e+05 1.67945508e+06
     2.30000000e+00 1.51800000e+01 1.49132000e+02 1.63033200e+03
     1.87184856e+04 1.01200000e+01 6.67920000e+01 6.56180800e+02
     7.17346080e+03 8.23613366e+04 6.56420000e+01 4.33237200e+02
     4.25622728e+03 4.65296753e+04 5.34225579e+05 4.74628000e+02
     3.13254480e+03 3.07748795e+04 3.36435312e+05 3.86274669e+06
     7.43500000e+00 4.90710000e+01 4.82085400e+02 5.27022540e+03
     6.05095393e+04 3.27140000e+01 2.15912400e+02 2.12117576e+03
     2.31889918e+04 2.66241973e+05 2.12194900e+02 1.40048634e+03
     1.37587173e+04 1.50412233e+05 1.72694225e+06 1.53428660e+03
     1.01262916e+04 9.94831431e+04 1.08756371e+06 1.24867485e+07]]

  1. पायथन में चेबीशेव बहुपद और x, y, z नमूना बिंदुओं का एक छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करें

    Chebyshev बहुपद और x, y, z नमूना बिंदुओं का छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करने के लिए, Python Numpy में chebyshev.chebvander() का उपयोग करें। यह विधि डिग्री डिग्री और नमूना बिंदुओं (x, y, z) के छद्म-वैंडरमंडमैट्रिक्स लौटाती है। पैरामीटर, x, y, z बिंदु निर्देशांक के सरणियाँ हैं, सभी एक ही आकार क

  1. पायथन में चेबीशेव बहुपद और x, y, z फ्लोटिंग पॉइंट ऑफ़ पॉइंट्स का छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करें

    Chebyshev बहुपद और x, y, z नमूना बिंदुओं का छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करने के लिए, Python Numpy में chebyshev.chebvander() का उपयोग करें। विधि डिग्री डिग्री और नमूना बिंदुओं (x, y, z) के छद्म-वैंडरमोंडेमेट्रिक्स लौटाती है। पैरामीटर, x, y, z बिंदु निर्देशांक के सरणियाँ हैं, सभी एक ही आकार क

  1. अजगर में हरमाइट बहुपद और x, y, z जटिल बिंदुओं का एक छद्म वेंडरमोंडे मैट्रिक्स उत्पन्न करें

    Hermite बहुपद और x, y, z नमूना बिंदुओं का छद्म वेंडरमोंड मैट्रिक्स उत्पन्न करने के लिए, Python Numpy में hermite.hermvander3d() का उपयोग करें। विधि छद्म-वेंडरमोंडेमेट्रिक्स लौटाती है। पैरामीटर, x, y, z बिंदु निर्देशांक के सरणियाँ हैं, सभी एक ही आकार के हैं। तत्वों में से कोई भी जटिल है या नहीं, इस प