MCPcopy Create free account
hub / github.com/numpy/numpy / polyder

Function polyder

numpy/lib/polynomial.py:374–446  ·  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

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

Callers 1

derivMethod · 0.70

Calls 1

poly1dClass · 0.85

Tested by

no test coverage detected