Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 :
(c1, c2)
| 439 | |
| 440 | |
| 441 | def hermemul(c1, c2): |
| 442 | """ |
| 443 | Multiply one Hermite series by another. |
| 444 | |
| 445 | Returns the product of two Hermite series `c1` * `c2`. The arguments |
| 446 | are sequences of coefficients, from lowest order "term" to highest, |
| 447 | e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. |
| 448 | |
| 449 | Parameters |
| 450 | ---------- |
| 451 | c1, c2 : array_like |
| 452 | 1-D arrays of Hermite series coefficients ordered from low to |
| 453 | high. |
| 454 | |
| 455 | Returns |
| 456 | ------- |
| 457 | out : ndarray |
| 458 | Of Hermite series coefficients representing their product. |
| 459 | |
| 460 | See Also |
| 461 | -------- |
| 462 | hermeadd, hermesub, hermemulx, hermediv, hermepow |
| 463 | |
| 464 | Notes |
| 465 | ----- |
| 466 | In general, the (polynomial) product of two C-series results in terms |
| 467 | that are not in the Hermite polynomial basis set. Thus, to express |
| 468 | the product as a Hermite series, it is necessary to "reproject" the |
| 469 | product onto said basis set, which may produce "unintuitive" (but |
| 470 | correct) results; see Examples section below. |
| 471 | |
| 472 | Examples |
| 473 | -------- |
| 474 | >>> from numpy.polynomial.hermite_e import hermemul |
| 475 | >>> hermemul([1, 2, 3], [0, 1, 2]) |
| 476 | array([14., 15., 28., 7., 6.]) |
| 477 | |
| 478 | """ |
| 479 | # s1, s2 are trimmed copies |
| 480 | [c1, c2] = pu.as_series([c1, c2]) |
| 481 | |
| 482 | if len(c1) > len(c2): |
| 483 | c = c2 |
| 484 | xs = c1 |
| 485 | else: |
| 486 | c = c1 |
| 487 | xs = c2 |
| 488 | |
| 489 | if len(c) == 1: |
| 490 | c0 = c[0]*xs |
| 491 | c1 = 0 |
| 492 | elif len(c) == 2: |
| 493 | c0 = c[0]*xs |
| 494 | c1 = c[1]*xs |
| 495 | else: |
| 496 | nd = len(c) |
| 497 | c0 = c[-2]*xs |
| 498 | c1 = c[-1]*xs |