chaospy.gradient¶
- chaospy.gradient(poly: Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]], numpoly.baseclass.ndpoly]) numpoly.baseclass.ndpoly [source]¶
Polynomial gradient operator.
- Args:
- poly:
Polynomial to differentiate. If polynomial vector is provided, the Jacobi-matrix is returned instead.
- Return:
Same as
poly
but with an extra first dimensions, one for each variable inpoly.indeterminants
, filled with gradient values.- Example:
>>> q0 = numpoly.variable() >>> poly = 5*q0**5+4 >>> numpoly.gradient(poly) polynomial([25*q0**4]) >>> q0, q1 = numpoly.variable(2) >>> poly = 4*q0**3+2*q1**2+3 >>> numpoly.gradient(poly) polynomial([12*q0**2, 4*q1]) >>> poly = numpoly.polynomial([1, q0**3, q0*q1**2+1]) >>> numpoly.gradient(poly) polynomial([[0, 3*q0**2, q1**2], [0, 0, 2*q0*q1]])