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

Function chebfromroots

numpy/polynomial/chebyshev.py:514–566  ·  view source on GitHub ↗

Generate a Chebyshev series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in Chebyshev form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must ap

(roots)

Source from the content-addressed store, hash-verified

512
513
514def chebfromroots(roots):
515 """
516 Generate a Chebyshev series with given roots.
517
518 The function returns the coefficients of the polynomial
519
520 .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),
521
522 in Chebyshev form, where the `r_n` are the roots specified in `roots`.
523 If a zero has multiplicity n, then it must appear in `roots` n times.
524 For instance, if 2 is a root of multiplicity three and 3 is a root of
525 multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The
526 roots can appear in any order.
527
528 If the returned coefficients are `c`, then
529
530 .. math:: p(x) = c_0 + c_1 * T_1(x) + ... + c_n * T_n(x)
531
532 The coefficient of the last term is not generally 1 for monic
533 polynomials in Chebyshev form.
534
535 Parameters
536 ----------
537 roots : array_like
538 Sequence containing the roots.
539
540 Returns
541 -------
542 out : ndarray
543 1-D array of coefficients. If all roots are real then `out` is a
544 real array, if some of the roots are complex, then `out` is complex
545 even if all the coefficients in the result are real (see Examples
546 below).
547
548 See Also
549 --------
550 numpy.polynomial.polynomial.polyfromroots
551 numpy.polynomial.legendre.legfromroots
552 numpy.polynomial.laguerre.lagfromroots
553 numpy.polynomial.hermite.hermfromroots
554 numpy.polynomial.hermite_e.hermefromroots
555
556 Examples
557 --------
558 >>> import numpy.polynomial.chebyshev as C
559 >>> C.chebfromroots((-1,0,1)) # x^3 - x relative to the standard basis
560 array([ 0. , -0.25, 0. , 0.25])
561 >>> j = complex(0,1)
562 >>> C.chebfromroots((-j,j)) # x^2 + 1 relative to the standard basis
563 array([1.5+0.j, 0. +0.j, 0.5+0.j])
564
565 """
566 return pu._fromroots(chebline, chebmul, roots)
567
568
569def chebadd(c1, c2):

Callers

nothing calls this directly

Calls 1

_fromrootsMethod · 0.80

Tested by

no test coverage detected