neulab/docprompting-conala huggingface dataset:
numpy.polynomial.legendre.poly2leg   polynomial.legendre.poly2leg(pol)[source]
 
Convert a polynomial to a Legendre series. Convert an array representing the coefficients of a polynomial (relative to the “standard” basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Legendre series, ordered from lowest to highest degree.  Parameters 
 
polarray_like


1-D array containing the polynomial coefficients    Returns 
 
cndarray


1-D array containing the coefficients of the equivalent Legendre series.      See also  leg2poly
  Notes The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples >>> from numpy import polynomial as P
>>> p = P.Polynomial(np.arange(4))
>>> p
Polynomial([0.,  1.,  2.,  3.], domain=[-1,  1], window=[-1,  1])
>>> c = P.Legendre(P.legendre.poly2leg(p.coef))
>>> c
Legendre([ 1.  ,  3.25,  1.  ,  0.75], domain=[-1,  1], window=[-1,  1]) # may vary
numpy.polynomial.polynomial.polyadd   polynomial.polynomial.polyadd(c1, c2)[source]
 
Add one polynomial to another. Returns the sum of two polynomials c1 + c2. The arguments are sequences of coefficients from lowest order term to highest, i.e., [1,2,3] represents the polynomial 1 + 2*x + 3*x**2.  Parameters 
 
c1, c2array_like


1-D arrays of polynomial coefficients ordered from low to high.    Returns 
 
outndarray


The coefficient array representing their sum.      See also  
polysub, polymulx, polymul, polydiv, polypow

  Examples >>> from numpy.polynomial import polynomial as P
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> sum = P.polyadd(c1,c2); sum
array([4.,  4.,  4.])
>>> P.polyval(2, sum) # 4 + 4(2) + 4(2**2)
28.0
numpy.polynomial.polynomial.polycompanion   polynomial.polynomial.polycompanion(c)[source]
 
Return the companion matrix of c. The companion matrix for power series cannot be made symmetric by scaling the basis, so this function differs from those for the orthogonal polynomials.  Parameters 
 
carray_like


1-D array of polynomial coefficients ordered from low to high degree.    Returns 
 
matndarray


Companion matrix of dimensions (deg, deg).     Notes  New in version 1.7.0.
numpy.polynomial.polynomial.polyder   polynomial.polynomial.polyder(c, m=1, scl=1, axis=0)[source]
 
Differentiate a polynomial. Returns the polynomial coefficients c differentiated m times along axis. At each iteration the result is multiplied by scl (the scaling factor is for use in a linear change of variable). The argument c is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the polynomial 1 + 2*x + 3*x**2 while [[1,2],[1,2]] represents 1 + 1*x + 2*y + 2*x*y if axis=0 is x and axis=1 is y.  Parameters 
 
carray_like


Array of polynomial coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.  
mint, optional


Number of derivatives taken, must be non-negative. (Default: 1)  
sclscalar, optional


Each differentiation is multiplied by scl. The end result is multiplication by scl**m. This is for use in a linear change of variable. (Default: 1)  
axisint, optional


Axis over which the derivative is taken. (Default: 0).  New in version 1.7.0.     Returns 
 
derndarray


Polynomial coefficients of the derivative.      See also  polyint
  Examples >>> from numpy.polynomial import polynomial as P
>>> c = (1,2,3,4) # 1 + 2x + 3x**2 + 4x**3
>>> P.polyder(c) # (d/dx)(c) = 2 + 6x + 12x**2
array([  2.,   6.,  12.])
>>> P.polyder(c,3) # (d**3/dx**3)(c) = 24
array([24.])
>>> P.polyder(c,scl=-1) # (d/d(-x))(c) = -2 - 6x - 12x**2
array([ -2.,  -6., -12.])
>>> P.polyder(c,2,-1) # (d**2/d(-x)**2)(c) = 6 + 24x
array([  6.,  24.])
numpy.polynomial.polynomial.polydiv   polynomial.polynomial.polydiv(c1, c2)[source]
 
Divide one polynomial by another. Returns the quotient-with-remainder of two polynomials c1 / c2. The arguments are sequences of coefficients, from lowest order term to highest, e.g., [1,2,3] represents 1 + 2*x + 3*x**2.  Parameters 
 
c1, c2array_like


1-D arrays of polynomial coefficients ordered from low to high.    Returns 
 
[quo, rem]ndarrays


Of coefficient series representing the quotient and remainder.      See also  
polyadd, polysub, polymulx, polymul, polypow

  Examples >>> from numpy.polynomial import polynomial as P
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> P.polydiv(c1,c2)
(array([3.]), array([-8., -4.]))
>>> P.polydiv(c2,c1)
(array([ 0.33333333]), array([ 2.66666667,  1.33333333])) # may vary
numpy.polynomial.polynomial.polyfromroots   polynomial.polynomial.polyfromroots(roots)[source]
 
Generate a monic polynomial with given roots. Return the coefficients of the polynomial  \[p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),\] where the r_n are the roots specified in roots. If a zero has multiplicity n, then it must appear in roots n times. For instance, if 2 is a root of multiplicity three and 3 is a root of multiplicity 2, then roots looks something like [2, 2, 2, 3, 3]. The roots can appear in any order. If the returned coefficients are c, then  \[p(x) = c_0 + c_1 * x + ... + x^n\] The coefficient of the last term is 1 for monic polynomials in this form.  Parameters 
 
rootsarray_like


Sequence containing the roots.    Returns 
 
outndarray


1-D array of the polynomial’s coefficients If all the roots are real, then out is also real, otherwise it is complex. (see Examples below).      See also  numpy.polynomial.chebyshev.chebfromroots
numpy.polynomial.legendre.legfromroots
numpy.polynomial.laguerre.lagfromroots
numpy.polynomial.hermite.hermfromroots
numpy.polynomial.hermite_e.hermefromroots
  Notes The coefficients are determined by multiplying together linear factors of the form (x - r_i), i.e.  \[p(x) = (x - r_0) (x - r_1) ... (x - r_n)\] where n == len(roots) - 1; note that this implies that 1 is always returned for \(a_n\). Examples >>> from numpy.polynomial import polynomial as P
>>> P.polyfromroots((-1,0,1)) # x(x - 1)(x + 1) = x^3 - x
array([ 0., -1.,  0.,  1.])
>>> j = complex(0,1)
>>> P.polyfromroots((-j,j)) # complex returned, though values are real
array([1.+0.j,  0.+0.j,  1.+0.j])
numpy.polynomial.polynomial.polygrid2d   polynomial.polynomial.polygrid2d(x, y, c)[source]
 
Evaluate a 2-D polynomial on the Cartesian product of x and y. This function returns the values:  \[p(a,b) = \sum_{i,j} c_{i,j} * a^i * b^j\] where the points (a, b) consist of all pairs formed by taking a from x and b from y. The resulting points form a grid with x in the first dimension and y in the second. The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c. If c has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape + y.shape.  Parameters 
 
x, yarray_like, compatible objects


The two dimensional series is evaluated at the points in the Cartesian product of x and y. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.  
carray_like


Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.    Returns 
 
valuesndarray, compatible object


The values of the two dimensional polynomial at points in the Cartesian product of x and y.      See also  
polyval, polyval2d, polyval3d, polygrid3d

  Notes  New in version 1.7.0.
numpy.polynomial.polynomial.polygrid3d   polynomial.polynomial.polygrid3d(x, y, z, c)[source]
 
Evaluate a 3-D polynomial on the Cartesian product of x, y and z. This function returns the values:  \[p(a,b,c) = \sum_{i,j,k} c_{i,j,k} * a^i * b^j * c^k\] where the points (a, b, c) consist of all triples formed by taking a from x, b from y, and c from z. The resulting points form a grid with x in the first dimension, y in the second, and z in the third. The parameters x, y, and z are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x, y, and z or their elements must support multiplication and addition both with themselves and with the elements of c. If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape.  Parameters 
 
x, y, zarray_like, compatible objects


The three dimensional series is evaluated at the points in the Cartesian product of x, y, and z. If x,`y`, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.  
carray_like


Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.    Returns 
 
valuesndarray, compatible object


The values of the two dimensional polynomial at points in the Cartesian product of x and y.      See also  
polyval, polyval2d, polygrid2d, polyval3d

  Notes  New in version 1.7.0.
numpy.polynomial.polynomial.polyint   polynomial.polynomial.polyint(c, m=1, k=[], lbnd=0, scl=1, axis=0)[source]
 
Integrate a polynomial. Returns the polynomial coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable. (“Buyer beware”: note that, depending on what one is doing, one may want scl to be the reciprocal of what one might expect; for more information, see the Notes section below.) The argument c is an array of coefficients, from low to high degree along each axis, e.g., [1,2,3] represents the polynomial 1 + 2*x + 3*x**2 while [[1,2],[1,2]] represents 1 + 1*x + 2*y + 2*x*y if axis=0 is x and axis=1 is y.  Parameters 
 
carray_like


1-D array of polynomial coefficients, ordered from low to high.  
mint, optional


Order of integration, must be positive. (Default: 1)  
k{[], list, scalar}, optional


Integration constant(s). The value of the first integral at zero is the first value in the list, the value of the second integral at zero is the second value, etc. If k == [] (the default), all constants are set to zero. If m == 1, a single scalar can be given instead of a list.  
lbndscalar, optional


The lower bound of the integral. (Default: 0)  
sclscalar, optional


Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1)  
axisint, optional


Axis over which the integral is taken. (Default: 0).  New in version 1.7.0.     Returns 
 
Sndarray


Coefficient array of the integral.    Raises 
 ValueError

If m < 1, len(k) > m, np.ndim(lbnd) != 0, or np.ndim(scl) != 0.      See also  polyder
  Notes Note that the result of each integration is multiplied by scl. Why is this important to note? Say one is making a linear change of variable \(u = ax + b\) in an integral relative to x. Then \(dx = du/a\), so one will need to set scl equal to \(1/a\) - perhaps not what one would have first thought. Examples >>> from numpy.polynomial import polynomial as P
>>> c = (1,2,3)
>>> P.polyint(c) # should return array([0, 1, 1, 1])
array([0.,  1.,  1.,  1.])
>>> P.polyint(c,3) # should return array([0, 0, 0, 1/6, 1/12, 1/20])
 array([ 0.        ,  0.        ,  0.        ,  0.16666667,  0.08333333, # may vary
         0.05      ])
>>> P.polyint(c,k=3) # should return array([3, 1, 1, 1])
array([3.,  1.,  1.,  1.])
>>> P.polyint(c,lbnd=-2) # should return array([6, 1, 1, 1])
array([6.,  1.,  1.,  1.])
>>> P.polyint(c,scl=-2) # should return array([0, -2, -2, -2])
array([ 0., -2., -2., -2.])
numpy.polynomial.polynomial.polyline   polynomial.polynomial.polyline(off, scl)[source]
 
Returns an array representing a linear polynomial.  Parameters 
 
off, sclscalars


The “y-intercept” and “slope” of the line, respectively.    Returns 
 
yndarray


This module’s representation of the linear polynomial off +
scl*x.      See also  numpy.polynomial.chebyshev.chebline
numpy.polynomial.legendre.legline
numpy.polynomial.laguerre.lagline
numpy.polynomial.hermite.hermline
numpy.polynomial.hermite_e.hermeline
  Examples >>> from numpy.polynomial import polynomial as P
>>> P.polyline(1,-1)
array([ 1, -1])
>>> P.polyval(1, P.polyline(1,-1)) # should be 0
0.0
numpy.polynomial.polynomial.polymul   polynomial.polynomial.polymul(c1, c2)[source]
 
Multiply one polynomial by another. Returns the product of two polynomials c1 * c2. The arguments are sequences of coefficients, from lowest order term to highest, e.g., [1,2,3] represents the polynomial 1 + 2*x + 3*x**2.  Parameters 
 
c1, c2array_like


1-D arrays of coefficients representing a polynomial, relative to the “standard” basis, and ordered from lowest order term to highest.    Returns 
 
outndarray


Of the coefficients of their product.      See also  
polyadd, polysub, polymulx, polydiv, polypow

  Examples >>> from numpy.polynomial import polynomial as P
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> P.polymul(c1,c2)
array([  3.,   8.,  14.,   8.,   3.])
numpy.polynomial.polynomial.polymulx   polynomial.polynomial.polymulx(c)[source]
 
Multiply a polynomial by x. Multiply the polynomial c by x, where x is the independent variable.  Parameters 
 
carray_like


1-D array of polynomial coefficients ordered from low to high.    Returns 
 
outndarray


Array representing the result of the multiplication.      See also  
polyadd, polysub, polymul, polydiv, polypow

  Notes  New in version 1.5.0.
numpy.polynomial.polynomial.Polynomial.__call__ method   polynomial.polynomial.Polynomial.__call__(arg)[source]
 
Call self as a function.
numpy.polynomial.polynomial.Polynomial.basis method   classmethod polynomial.polynomial.Polynomial.basis(deg, domain=None, window=None)[source]
 
Series basis polynomial of degree deg. Returns the series representing the basis polynomial of degree deg.  New in version 1.7.0.   Parameters 
 
degint


Degree of the basis polynomial for the series. Must be >= 0.  
domain{None, array_like}, optional


If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.  
window{None, array_like}, optional


If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.    Returns 
 
new_seriesseries


A series with the coefficient of the deg term set to one and all others zero.
numpy.polynomial.polynomial.Polynomial.cast method   classmethod polynomial.polynomial.Polynomial.cast(series, domain=None, window=None)[source]
 
Convert series to series of this class. The series is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert method.  New in version 1.7.0.   Parameters 
 
seriesseries


The series instance to be converted.  
domain{None, array_like}, optional


If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.  
window{None, array_like}, optional


If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.    Returns 
 
new_seriesseries


A series of the same kind as the calling class and equal to series when evaluated.      See also  convert

similar instance method
numpy.polynomial.polynomial.Polynomial.convert method   polynomial.polynomial.Polynomial.convert(domain=None, kind=None, window=None)[source]
 
Convert series to a different kind and/or domain and/or window.  Parameters 
 
domainarray_like, optional


The domain of the converted series. If the value is None, the default domain of kind is used.  
kindclass, optional


The polynomial series type class to which the current instance should be converted. If kind is None, then the class of the current instance is used.  
windowarray_like, optional


The window of the converted series. If the value is None, the default window of kind is used.    Returns 
 
new_seriesseries


The returned class can be of different type than the current instance and/or have a different domain and/or different window.     Notes Conversion between domains and class types can result in numerically ill defined series.
numpy.polynomial.polynomial.Polynomial.copy method   polynomial.polynomial.Polynomial.copy()[source]
 
Return a copy.  Returns 
 
new_seriesseries


Copy of self.
numpy.polynomial.polynomial.Polynomial.cutdeg method   polynomial.polynomial.Polynomial.cutdeg(deg)[source]
 
Truncate series to the given degree. Reduce the degree of the series to deg by discarding the high order terms. If deg is greater than the current degree a copy of the current series is returned. This can be useful in least squares where the coefficients of the high degree terms may be very small.  New in version 1.5.0.   Parameters 
 
degnon-negative int


The series is reduced to degree deg by discarding the high order terms. The value of deg must be a non-negative integer.    Returns 
 
new_seriesseries


New instance of series with reduced degree.
numpy.polynomial.polynomial.Polynomial.degree method   polynomial.polynomial.Polynomial.degree()[source]
 
The degree of the series.  New in version 1.5.0.   Returns 
 
degreeint


Degree of the series, one less than the number of coefficients.
numpy.polynomial.polynomial.Polynomial.deriv method   polynomial.polynomial.Polynomial.deriv(m=1)[source]
 
Differentiate. Return a series instance of that is the derivative of the current series.  Parameters 
 
mnon-negative int


Find the derivative of order m.    Returns 
 
new_seriesseries


A new series representing the derivative. The domain is the same as the domain of the differentiated series.
numpy.polynomial.polynomial.Polynomial.domain attribute   polynomial.polynomial.Polynomial.domain = array([-1, 1])
numpy.polynomial.polynomial.Polynomial.fit method   classmethod polynomial.polynomial.Polynomial.fit(x, y, deg, domain=None, rcond=None, full=False, w=None, window=None)[source]
 
Least squares fit to data. Return a series instance that is the least squares fit to the data y sampled at x. The domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning.  Parameters 
 
xarray_like, shape (M,)


x-coordinates of the M sample points (x[i], y[i]).  
yarray_like, shape (M,)


y-coordinates of the M sample points (x[i], y[i]).  
degint or 1-D array_like


Degree(s) of the fitting polynomials. If deg is a single integer all terms up to and including the deg’th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead.  
domain{None, [beg, end], []}, optional


Domain to use for the returned series. If None, then a minimal domain that covers the points x is chosen. If [] the class domain is used. The default value was the class domain in NumPy 1.4 and None in later versions. The [] option was added in numpy 1.5.0.  
rcondfloat, optional


Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.  
fullbool, optional


Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.  
warray_like, shape (M,), optional


Weights. If not None, the weight w[i] applies to the unsquared residual y[i] - y_hat[i] at x[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. When using inverse-variance weighting, use w[i] = 1/sigma(y[i]). The default value is None.  New in version 1.5.0.   
window{[beg, end]}, optional


Window to use for the returned series. The default value is the default class domain  New in version 1.6.0.     Returns 
 
new_seriesseries


A series that represents the least squares fit to the data and has the domain and window specified in the call. If the coefficients for the unscaled and unshifted basis polynomials are of interest, do new_series.convert().coef.  
[resid, rank, sv, rcond]list


These values are only returned if full == True  resid – sum of squared residuals of the least squares fit rank – the numerical rank of the scaled Vandermonde matrix sv – singular values of the scaled Vandermonde matrix rcond – value of rcond.  For more details, see linalg.lstsq.
numpy.polynomial.polynomial.Polynomial.fromroots method   classmethod polynomial.polynomial.Polynomial.fromroots(roots, domain=[], window=None)[source]
 
Return series instance that has the specified roots. Returns a series representing the product (x - r[0])*(x - r[1])*...*(x - r[n-1]), where r is a list of roots.  Parameters 
 
rootsarray_like


List of roots.  
domain{[], None, array_like}, optional


Domain for the resulting series. If None the domain is the interval from the smallest root to the largest. If [] the domain is the class domain. The default is [].  
window{None, array_like}, optional


Window for the returned series. If None the class window is used. The default is None.    Returns 
 
new_seriesseries


Series with the specified roots.
numpy.polynomial.polynomial.Polynomial.has_samecoef method   polynomial.polynomial.Polynomial.has_samecoef(other)[source]
 
Check if coefficients match.  New in version 1.6.0.   Parameters 
 
otherclass instance


The other class must have the coef attribute.    Returns 
 
boolboolean


True if the coefficients are the same, False otherwise.
numpy.polynomial.polynomial.Polynomial.has_samedomain method   polynomial.polynomial.Polynomial.has_samedomain(other)[source]
 
Check if domains match.  New in version 1.6.0.   Parameters 
 
otherclass instance


The other class must have the domain attribute.    Returns 
 
boolboolean


True if the domains are the same, False otherwise.
numpy.polynomial.polynomial.Polynomial.has_sametype method   polynomial.polynomial.Polynomial.has_sametype(other)[source]
 
Check if types match.  New in version 1.7.0.   Parameters 
 
otherobject


Class instance.    Returns 
 
boolboolean


True if other is same class as self
numpy.polynomial.polynomial.Polynomial.has_samewindow method   polynomial.polynomial.Polynomial.has_samewindow(other)[source]
 
Check if windows match.  New in version 1.6.0.   Parameters 
 
otherclass instance


The other class must have the window attribute.    Returns 
 
boolboolean


True if the windows are the same, False otherwise.
numpy.polynomial.polynomial.Polynomial.identity method   classmethod polynomial.polynomial.Polynomial.identity(domain=None, window=None)[source]
 
Identity function. If p is the returned series, then p(x) == x for all values of x.  Parameters 
 
domain{None, array_like}, optional


If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.  
window{None, array_like}, optional


If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.    Returns 
 
new_seriesseries


Series of representing the identity.