| 2 | |
| 3 | A lazy laurent series computes coefficients only when demanded or needed. In a sense, lazy laurent series are laurent series of infinite precision. |
| 4 | |
| 5 | A generating function example from the code: |
| 6 | {{{ |
| 7 | Generating functions are laurent series over the integer ring:: |
| 8 | |
| 9 | sage: from sage.rings.lazy_laurent_series_ring import LazyLaurentSeriesRing |
| 10 | sage: L = LazyLaurentSeriesRing(ZZ, 'z') |
| 11 | |
| 12 | This defines the generating function of Fibonacci sequence:: |
| 13 | |
| 14 | sage: def coeff(s, i): |
| 15 | ....: if i in [0, 1]: |
| 16 | ....: return 1 |
| 17 | ....: else: |
| 18 | ....: return s.coefficient(i - 1) + s.coefficient(i - 2) |
| 19 | ....: |
| 20 | sage: f = L.series(coeff, valuation=0); f |
| 21 | 1 + z + 2*z^2 + 3*z^3 + 5*z^4 + 8*z^5 + 13*z^6 + ... |
| 22 | |
| 23 | The 100th element of Fibonacci sequence can be obtained from the generating |
| 24 | function:: |
| 25 | |
| 26 | sage: f.coefficient(100) |
| 27 | 573147844013817084101 |
| 28 | }}} |
| 29 | |
| 30 | Lazy laurent series is of course useful for other things. This will be used to implement infinite precision laurent series expansion of algebraic functions in function fields, as a sequel to #27418. |