MCPcopy Index your code
hub / github.com/numpy/numpy / polyder

Function polyder

numpy/lib/_polynomial_impl.py:378–453  ·  view source on GitHub ↗

Return the derivative of the specified order of a polynomial. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :doc:`transi

(p, m=1)

Source from the content-addressed store, hash-verified

376
377@array_function_dispatch(_polyder_dispatcher)
378def polyder(p, m=1):
379 """
380 Return the derivative of the specified order of a polynomial.
381
382 .. note::
383 This forms part of the old polynomial API. Since version 1.4, the
384 new polynomial API defined in `numpy.polynomial` is preferred.
385 A summary of the differences can be found in the
386 :doc:`transition guide </reference/routines.polynomials>`.
387
388 Parameters
389 ----------
390 p : poly1d or sequence
391 Polynomial to differentiate.
392 A sequence is interpreted as polynomial coefficients, see `poly1d`.
393 m : int, optional
394 Order of differentiation (default: 1)
395
396 Returns
397 -------
398 der : poly1d
399 A new polynomial representing the derivative.
400
401 See Also
402 --------
403 polyint : Anti-derivative of a polynomial.
404 poly1d : Class for one-dimensional polynomials.
405
406 Examples
407 --------
408
409 The derivative of the polynomial :math:`x^3 + x^2 + x^1 + 1` is:
410
411 >>> import numpy as np
412
413 >>> p = np.poly1d([1,1,1,1])
414 >>> p2 = np.polyder(p)
415 >>> p2
416 poly1d([3, 2, 1])
417
418 which evaluates to:
419
420 >>> p2(2.)
421 17.0
422
423 We can verify this, approximating the derivative with
424 ``(f(x + h) - f(x))/h``:
425
426 >>> (p(2. + 0.001) - p(2.)) / 0.001
427 17.007000999997857
428
429 The fourth-order derivative of a 3rd-order polynomial is zero:
430
431 >>> np.polyder(p, 2)
432 poly1d([6, 2])
433 >>> np.polyder(p, 3)
434 poly1d([6])
435 >>> np.polyder(p, 4)

Callers 1

derivMethod · 0.70

Calls 1

poly1dClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…