Compute the roots of a Laguerre series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * L_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the
(c)
| 1517 | |
| 1518 | |
| 1519 | def lagroots(c): |
| 1520 | """ |
| 1521 | Compute the roots of a Laguerre series. |
| 1522 | |
| 1523 | Return the roots (a.k.a. "zeros") of the polynomial |
| 1524 | |
| 1525 | .. math:: p(x) = \\sum_i c[i] * L_i(x). |
| 1526 | |
| 1527 | Parameters |
| 1528 | ---------- |
| 1529 | c : 1-D array_like |
| 1530 | 1-D array of coefficients. |
| 1531 | |
| 1532 | Returns |
| 1533 | ------- |
| 1534 | out : ndarray |
| 1535 | Array of the roots of the series. If all the roots are real, |
| 1536 | then `out` is also real, otherwise it is complex. |
| 1537 | |
| 1538 | See Also |
| 1539 | -------- |
| 1540 | numpy.polynomial.polynomial.polyroots |
| 1541 | numpy.polynomial.legendre.legroots |
| 1542 | numpy.polynomial.chebyshev.chebroots |
| 1543 | numpy.polynomial.hermite.hermroots |
| 1544 | numpy.polynomial.hermite_e.hermeroots |
| 1545 | |
| 1546 | Notes |
| 1547 | ----- |
| 1548 | The root estimates are obtained as the eigenvalues of the companion |
| 1549 | matrix, Roots far from the origin of the complex plane may have large |
| 1550 | errors due to the numerical instability of the series for such |
| 1551 | values. Roots with multiplicity greater than 1 will also show larger |
| 1552 | errors as the value of the series near such points is relatively |
| 1553 | insensitive to errors in the roots. Isolated roots near the origin can |
| 1554 | be improved by a few iterations of Newton's method. |
| 1555 | |
| 1556 | The Laguerre series basis polynomials aren't powers of `x` so the |
| 1557 | results of this function may seem unintuitive. |
| 1558 | |
| 1559 | Examples |
| 1560 | -------- |
| 1561 | >>> from numpy.polynomial.laguerre import lagroots, lagfromroots |
| 1562 | >>> coef = lagfromroots([0, 1, 2]) |
| 1563 | >>> coef |
| 1564 | array([ 2., -8., 12., -6.]) |
| 1565 | >>> lagroots(coef) |
| 1566 | array([-4.4408921e-16, 1.0000000e+00, 2.0000000e+00]) |
| 1567 | |
| 1568 | """ |
| 1569 | # c is a trimmed copy |
| 1570 | [c] = pu.as_series([c]) |
| 1571 | if len(c) <= 1: |
| 1572 | return np.array([], dtype=c.dtype) |
| 1573 | if len(c) == 2: |
| 1574 | return np.array([1 + c[0] / c[1]]) |
| 1575 | |
| 1576 | # rotated companion matrix reduces error |
nothing calls this directly
no test coverage detected
searching dependent graphs…