Divide one Chebyshev series by another. Returns the quotient-with-remainder of two Chebyshev series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters --
(c1, c2)
| 746 | |
| 747 | |
| 748 | def chebdiv(c1, c2): |
| 749 | """ |
| 750 | Divide one Chebyshev series by another. |
| 751 | |
| 752 | Returns the quotient-with-remainder of two Chebyshev series |
| 753 | `c1` / `c2`. The arguments are sequences of coefficients from lowest |
| 754 | order "term" to highest, e.g., [1,2,3] represents the series |
| 755 | ``T_0 + 2*T_1 + 3*T_2``. |
| 756 | |
| 757 | Parameters |
| 758 | ---------- |
| 759 | c1, c2 : array_like |
| 760 | 1-D arrays of Chebyshev series coefficients ordered from low to |
| 761 | high. |
| 762 | |
| 763 | Returns |
| 764 | ------- |
| 765 | [quo, rem] : ndarrays |
| 766 | Of Chebyshev series coefficients representing the quotient and |
| 767 | remainder. |
| 768 | |
| 769 | See Also |
| 770 | -------- |
| 771 | chebadd, chebsub, chebmulx, chebmul, chebpow |
| 772 | |
| 773 | Notes |
| 774 | ----- |
| 775 | In general, the (polynomial) division of one C-series by another |
| 776 | results in quotient and remainder terms that are not in the Chebyshev |
| 777 | polynomial basis set. Thus, to express these results as C-series, it |
| 778 | is typically necessary to "reproject" the results onto said basis |
| 779 | set, which typically produces "unintuitive" (but correct) results; |
| 780 | see Examples section below. |
| 781 | |
| 782 | Examples |
| 783 | -------- |
| 784 | >>> from numpy.polynomial import chebyshev as C |
| 785 | >>> c1 = (1,2,3) |
| 786 | >>> c2 = (3,2,1) |
| 787 | >>> C.chebdiv(c1,c2) # quotient "intuitive," remainder not |
| 788 | (array([3.]), array([-8., -4.])) |
| 789 | >>> c2 = (0,1,2,3) |
| 790 | >>> C.chebdiv(c2,c1) # neither "intuitive" |
| 791 | (array([0., 2.]), array([-2., -4.])) |
| 792 | |
| 793 | """ |
| 794 | # c1, c2 are trimmed copies |
| 795 | [c1, c2] = pu.as_series([c1, c2]) |
| 796 | if c2[-1] == 0: |
| 797 | raise ZeroDivisionError # FIXME: add message with details to exception |
| 798 | |
| 799 | # note: this is more efficient than `pu._div(chebmul, c1, c2)` |
| 800 | lc1 = len(c1) |
| 801 | lc2 = len(c2) |
| 802 | if lc1 < lc2: |
| 803 | return c1[:1] * 0, c1 |
| 804 | elif lc2 == 1: |
| 805 | return c1 / c2[-1], c1[:1] * 0 |
nothing calls this directly
no test coverage detected
searching dependent graphs…