Compute the roots of a Hermite series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * H_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the r
(c)
| 1535 | |
| 1536 | |
| 1537 | def hermroots(c): |
| 1538 | """ |
| 1539 | Compute the roots of a Hermite series. |
| 1540 | |
| 1541 | Return the roots (a.k.a. "zeros") of the polynomial |
| 1542 | |
| 1543 | .. math:: p(x) = \\sum_i c[i] * H_i(x). |
| 1544 | |
| 1545 | Parameters |
| 1546 | ---------- |
| 1547 | c : 1-D array_like |
| 1548 | 1-D array of coefficients. |
| 1549 | |
| 1550 | Returns |
| 1551 | ------- |
| 1552 | out : ndarray |
| 1553 | Array of the roots of the series. If all the roots are real, |
| 1554 | then `out` is also real, otherwise it is complex. |
| 1555 | |
| 1556 | See Also |
| 1557 | -------- |
| 1558 | numpy.polynomial.polynomial.polyroots |
| 1559 | numpy.polynomial.legendre.legroots |
| 1560 | numpy.polynomial.laguerre.lagroots |
| 1561 | numpy.polynomial.chebyshev.chebroots |
| 1562 | numpy.polynomial.hermite_e.hermeroots |
| 1563 | |
| 1564 | Notes |
| 1565 | ----- |
| 1566 | The root estimates are obtained as the eigenvalues of the companion |
| 1567 | matrix, Roots far from the origin of the complex plane may have large |
| 1568 | errors due to the numerical instability of the series for such |
| 1569 | values. Roots with multiplicity greater than 1 will also show larger |
| 1570 | errors as the value of the series near such points is relatively |
| 1571 | insensitive to errors in the roots. Isolated roots near the origin can |
| 1572 | be improved by a few iterations of Newton's method. |
| 1573 | |
| 1574 | The Hermite series basis polynomials aren't powers of `x` so the |
| 1575 | results of this function may seem unintuitive. |
| 1576 | |
| 1577 | Examples |
| 1578 | -------- |
| 1579 | >>> from numpy.polynomial.hermite import hermroots, hermfromroots |
| 1580 | >>> coef = hermfromroots([-1, 0, 1]) |
| 1581 | >>> coef |
| 1582 | array([0. , 0.25 , 0. , 0.125]) |
| 1583 | >>> hermroots(coef) |
| 1584 | array([-1.00000000e+00, -1.38777878e-17, 1.00000000e+00]) |
| 1585 | |
| 1586 | """ |
| 1587 | # c is a trimmed copy |
| 1588 | [c] = pu.as_series([c]) |
| 1589 | if len(c) <= 1: |
| 1590 | return np.array([], dtype=c.dtype) |
| 1591 | if len(c) == 2: |
| 1592 | return np.array([-.5 * c[0] / c[1]]) |
| 1593 | |
| 1594 | # rotated companion matrix reduces error |
nothing calls this directly
no test coverage detected
searching dependent graphs…