Compute the roots of a HermiteE series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * He_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the
(c)
| 1443 | |
| 1444 | |
| 1445 | def hermeroots(c): |
| 1446 | """ |
| 1447 | Compute the roots of a HermiteE series. |
| 1448 | |
| 1449 | Return the roots (a.k.a. "zeros") of the polynomial |
| 1450 | |
| 1451 | .. math:: p(x) = \\sum_i c[i] * He_i(x). |
| 1452 | |
| 1453 | Parameters |
| 1454 | ---------- |
| 1455 | c : 1-D array_like |
| 1456 | 1-D array of coefficients. |
| 1457 | |
| 1458 | Returns |
| 1459 | ------- |
| 1460 | out : ndarray |
| 1461 | Array of the roots of the series. If all the roots are real, |
| 1462 | then `out` is also real, otherwise it is complex. |
| 1463 | |
| 1464 | See Also |
| 1465 | -------- |
| 1466 | numpy.polynomial.polynomial.polyroots |
| 1467 | numpy.polynomial.legendre.legroots |
| 1468 | numpy.polynomial.laguerre.lagroots |
| 1469 | numpy.polynomial.hermite.hermroots |
| 1470 | numpy.polynomial.chebyshev.chebroots |
| 1471 | |
| 1472 | Notes |
| 1473 | ----- |
| 1474 | The root estimates are obtained as the eigenvalues of the companion |
| 1475 | matrix, Roots far from the origin of the complex plane may have large |
| 1476 | errors due to the numerical instability of the series for such |
| 1477 | values. Roots with multiplicity greater than 1 will also show larger |
| 1478 | errors as the value of the series near such points is relatively |
| 1479 | insensitive to errors in the roots. Isolated roots near the origin can |
| 1480 | be improved by a few iterations of Newton's method. |
| 1481 | |
| 1482 | The HermiteE series basis polynomials aren't powers of `x` so the |
| 1483 | results of this function may seem unintuitive. |
| 1484 | |
| 1485 | Examples |
| 1486 | -------- |
| 1487 | >>> from numpy.polynomial.hermite_e import hermeroots, hermefromroots |
| 1488 | >>> coef = hermefromroots([-1, 0, 1]) |
| 1489 | >>> coef |
| 1490 | array([0., 2., 0., 1.]) |
| 1491 | >>> hermeroots(coef) |
| 1492 | array([-1., 0., 1.]) # may vary |
| 1493 | |
| 1494 | """ |
| 1495 | # c is a trimmed copy |
| 1496 | [c] = pu.as_series([c]) |
| 1497 | if len(c) <= 1: |
| 1498 | return np.array([], dtype=c.dtype) |
| 1499 | if len(c) == 2: |
| 1500 | return np.array([-c[0]/c[1]]) |
| 1501 | |
| 1502 | # rotated companion matrix reduces error |
nothing calls this directly
no test coverage detected