Unmap the auto-generated constructor and replace it with a better one.
The primary difference from Series
is the IFn
implementation; application of a power series multiples each coefficient by a successively larger power of its (single, for now) argument.
TODO Modify this description once we implement multivariable power series!
These exposed objects are PowerSeries
instances, because the concepts of zero, one and identity don't make sense unless you interpret these as coefficients on a power series.
To go the other way we need Taylor's theorem to give us a power series:
Given some power series Loading..., we can "apply" the series to a value Loading... by multiplying each entry Loading... by Loading...:
Once a PowerSeries
has been applied, it becomes a Series
.
What does it mean to apply a Series
? The concept only makes sense if the series contains "applicables", or objects that can act as functions themselves.
If it does, then application of a series to some argument list xs
means applying each series element to xs
.
One further wrinkle occurs if the applicable in some position returns a series. value
should combine all of these resulting series, with each series shifted by its initial position in the first series. Concretely, suppose that Loading... has the form:
Then, this series applied to x should yield the series of values (A1, (+ A2 B1), (+ A3 B2 C1), ...)
Here's the implementation:
The following section defines a number of built in series that come up often enough to be included. There are, of course, far more! Please feel free to open a PR if you have a series you think should be included.
These are interesting sequences, not taylor series, but nice to have in a library like Emmy.
This section installs Series
and PowerSeries
into the Emmy generic arithmetic system.
A key idea here is that all "coefficients" of a series must be some kind derived from ::coseries
. This is not true in the Scheme scmutils library; in that library, anything that responds false to series?
is game for interaction with series objects.
NOTE This might be the right way to go. Feel free to experiment.
All generic methods:
This section does not define methods that coerce Series
=> PowerSeries
or vice versa. Users should do this explicitly.
A PowerSeries
is a single variable function; we extend the following methods to PowerSeries
in the same style as they're extended for functions. Each of the following act like function composition, and compose their operation with the function represented by the PowerSeries
.
If s
is a PowerSeries
that applies as (s x)
, (g/exp s)
returns a series that represents (g/exp (s x))
.
For a Series
, the derivative operation assumes that the series contains applicables that can take their own partial derivatives.
A PowerSeries
is itself a single-variable function, so g/partial-derivative
simply takes the series derivative of the contained sequence.
This is suspect, since [[Series]], unlike [[PowerSeries]], are general infinite sequences and not necessarily interpreted as polynomials. This decision follows scmutils
convention.