This notebook is licenced under CC BY-SA 4.0.

FriCAS Tutorial (Univariate and Multivariate Taylor Series)

Ralf Hemmecke <ralf@hemmecke.org>

Sources at Github.

In [1]:
)set message type off
)set output algebra off
setFormat!(FormatMathJax)$JFriCASSupport
)set message type on
In [2]:
)version
Value = "FriCAS a9422d32eb6f6b03d98ac6adfc9bf05ec0f5e8bd compiled at Sa 03 Apr 2021 00:29:13 CEST"

Univariate Taylor series

FriCAS can deal with power series in a simple manner.

In [3]:
x := taylor 'x;
sinh x
Out[3]:
\[ x+\frac{1}{6}\, {x}^{3}+\frac{1}{120}\, {x}^{5}+\frac{1}{5040}\, {x}^{7}+\frac{1}{362880}\, {x}^{9}+O\left({x}^{11}\right) \]

However, sometimes one wants to be more precise with the domain that the object lives in. If, for example, we don't want power series over the general expression domain as exemplified above, we can give the coefficient domain explicitly.

In [8]:
Z ==> Integer;
Q ==> Fraction Z;
Ux ==> UnivariateTaylorSeries(Q, 'x, 0);
ux: Ux := 'x;
sinh(ux)
Out[8]:
Out[8]:
Out[8]:
Out[8]:
\[ x+\frac{1}{6}\, {x}^{3}+\frac{1}{120}\, {x}^{5}+\frac{1}{5040}\, {x}^{7}+\frac{1}{362880}\, {x}^{9}+O\left({x}^{11}\right) \]

Combination of univariate Taylor series

The FriCAS interpreter is smart enough to create an appropriate type if two univariate Taylor series interact.

However, as seen below, the resulting domain is something like $\mathbb{Q}[[x]][[y]]$, i.e., univariate power series in y with coefficients that are univariate power series in x that have rational coefficients.

In [11]:
Uy ==> UnivariateTaylorSeries(Q, 'y, 0);
uy: Uy := 'y;
cosh(uy)
Out[11]:
Out[11]:
\[ 1+\frac{1}{2}\, {y}^{2}+\frac{1}{24}\, {y}^{4}+\frac{1}{720}\, {y}^{6}+\frac{1}{40320}\, {y}^{8}+\frac{1}{3628800}\, {y}^{10}+O\left({y}^{11}\right) \]
In [12]:
sinh(ux)*cosh(uy)
Out[12]:
\[ x+\frac{1}{6}\, {x}^{3}+\frac{1}{120}\, {x}^{5}+\frac{1}{5040}\, {x}^{7}+\frac{1}{362880}\, {x}^{9}+O\left({x}^{11}\right)+\left(\frac{1}{2}\, x+\frac{1}{12}\, {x}^{3}+\frac{1}{240}\, {x}^{5}+\frac{1}{10080}\, {x}^{7}+\frac{1}{725760}\, {x}^{9}+O\left({x}^{11}\right)\right)\, {y}^{2}+\left(\frac{1}{24}\, x+\frac{1}{144}\, {x}^{3}+\frac{1}{2880}\, {x}^{5}+\frac{1}{120960}\, {x}^{7}+\frac{1}{8709120}\, {x}^{9}+O\left({x}^{11}\right)\right)\, {y}^{4}+\left(\frac{1}{720}\, x+\frac{1}{4320}\, {x}^{3}+\frac{1}{86400}\, {x}^{5}+\frac{1}{3628800}\, {x}^{7}+\frac{1}{261273600}\, {x}^{9}+O\left({x}^{11}\right)\right)\, {y}^{6}+\left(\frac{1}{40320}\, x+\frac{1}{241920}\, {x}^{3}+\frac{1}{4838400}\, {x}^{5}+\frac{1}{203212800}\, {x}^{7}+\frac{1}{14631321600}\, {x}^{9}+O\left({x}^{11}\right)\right)\, {y}^{8}+\left(\frac{1}{3628800}\, x+\frac{1}{21772800}\, {x}^{3}+\frac{1}{435456000}\, {x}^{5}+\frac{1}{18289152000}\, {x}^{7}+\frac{1}{1316818944000}\, {x}^{9}+O\left({x}^{11}\right)\right)\, {y}^{10}+O\left({y}^{11}\right) \]

As a general rule, the FriCAS interpreter tries to find a "better coefficient domain" if something does not fit into the type of the current object in order to construct a more general domain that can hold the result of the operation.

In the case above that is probably not what we expected or wanted.

Multivariate Taylor series in infinitely many variables

There is a domain in FriCAS that is similar to the Polynomial(Q) domain. TaylorSeries(Q) is the domain of power series over $\mathbb{Q}$ in infinitely many variables.

With that domain the input is as simple as for univariate power series.

In [16]:
T ==> TaylorSeries Q;
tx:T := 'x;
ty:T := 'y;
sinh(tx)*cosh(ty)
Out[16]:
Out[16]:
\[ x+\left(\frac{1}{2}\, x\, {y}^{2}+\frac{1}{6}\, {x}^{3}\right)+\left(\frac{1}{24}\, x\, {y}^{4}+\frac{1}{12}\, {x}^{3}\, {y}^{2}+\frac{1}{120}\, {x}^{5}\right)+\left(\frac{1}{720}\, x\, {y}^{6}+\frac{1}{144}\, {x}^{3}\, {y}^{4}+\frac{1}{240}\, {x}^{5}\, {y}^{2}+\frac{1}{5040}\, {x}^{7}\right)+\left(\frac{1}{40320}\, x\, {y}^{8}+\frac{1}{4320}\, {x}^{3}\, {y}^{6}+\frac{1}{2880}\, {x}^{5}\, {y}^{4}+\frac{1}{10080}\, {x}^{7}\, {y}^{2}+\frac{1}{362880}\, {x}^{9}\right)+O\left(11\right) \]

Multivariate TaylorSeries in two variables

FriCAS allows to be more precise with multivariate power series. It is possible to create multivariate power series in a given number of variables. Such a construction is, however, a bit more involved.

The domain (named $M$ below') is modelled as a univariate power series over bivariate polynomials where the n-th coefficient of the series is the polynomial consisting of all (bivariate) terms of degree $n$.

Thus we first have to create a bivariate polynomial domain. From this construction, it should be clear how to create multivariate series in three or more variables.

In [23]:
vl: List Symbol := ['x, 'y];
V ==> OrderedVariableList vl;
P ==> SparseMultivariatePolynomial(Q, V);
M ==> SparseMultivariateTaylorSeries(Q, V, P);
mx: M := monomial(1$M, 'x, 1);
my: M := monomial(1$M, 'y, 1);
sinh(mx)*cosh(my)
Out[23]:
Out[23]:
Out[23]:
Out[23]:
Out[23]:
\[ x+\left(\frac{1}{6}\, {x}^{3}+\frac{1}{2}\, {y}^{2}\, x\right)+\left(\frac{1}{120}\, {x}^{5}+\frac{1}{12}\, {y}^{2}\, {x}^{3}+\frac{1}{24}\, {y}^{4}\, x\right)+\left(\frac{1}{5040}\, {x}^{7}+\frac{1}{240}\, {y}^{2}\, {x}^{5}+\frac{1}{144}\, {y}^{4}\, {x}^{3}+\frac{1}{720}\, {y}^{6}\, x\right)+\left(\frac{1}{362880}\, {x}^{9}+\frac{1}{10080}\, {y}^{2}\, {x}^{7}+\frac{1}{2880}\, {y}^{4}\, {x}^{5}+\frac{1}{4320}\, {y}^{6}\, {x}^{3}+\frac{1}{40320}\, {y}^{8}\, x\right)+O\left(11\right) \]
In [25]:
t1: M := 1/t0
Out[25]:
\[ 1+x+\left({x}^{2}+y\, x\right)+\left({x}^{3}+2\, y\, {x}^{2}\right)+\left({x}^{4}+3\, y\, {x}^{3}+{y}^{2}\, {x}^{2}\right)+\left({x}^{5}+4\, y\, {x}^{4}+3\, {y}^{2}\, {x}^{3}\right)+\left({x}^{6}+5\, y\, {x}^{5}+6\, {y}^{2}\, {x}^{4}+{y}^{3}\, {x}^{3}\right)+\left({x}^{7}+6\, y\, {x}^{6}+10\, {y}^{2}\, {x}^{5}+4\, {y}^{3}\, {x}^{4}\right)+\left({x}^{8}+7\, y\, {x}^{7}+15\, {y}^{2}\, {x}^{6}+10\, {y}^{3}\, {x}^{5}+{y}^{4}\, {x}^{4}\right)+\left({x}^{9}+8\, y\, {x}^{8}+21\, {y}^{2}\, {x}^{7}+20\, {y}^{3}\, {x}^{6}+5\, {y}^{4}\, {x}^{5}\right)+\left({x}^{10}+9\, y\, {x}^{9}+28\, {y}^{2}\, {x}^{8}+35\, {y}^{3}\, {x}^{7}+15\, {y}^{4}\, {x}^{6}+{y}^{5}\, {x}^{5}\right)+O\left(11\right) \]
In [26]:
t2: M := 1/t1

Multivariate Taylor series with unknown coefficients

We want to generate taylor series with unknown coefficients.

In [33]:
vl: List Symbol := ['x, 'y];
V ==> OrderedVariableList vl
E ==> Expression Integer
R ==> SparseMultivariatePolynomial(E, V)
S ==> SparseMultivariateTaylorSeries(E, V, R)
X: S := monomial(1$R, 'x, 1);
Y: S := monomial(1$R, 'y, 1);
In [34]:
sx:S := recip(1-X)
Out[34]:
\[ 1+x+{x}^{2}+{x}^{3}+{x}^{4}+{x}^{5}+{x}^{6}+{x}^{7}+{x}^{8}+{x}^{9}+{x}^{10}+O\left(11\right) \]
In [35]:
sy:S := recip(1-Y)
Out[35]:
\[ 1+y+{y}^{2}+{y}^{3}+{y}^{4}+{y}^{5}+{y}^{6}+{y}^{7}+{y}^{8}+{y}^{9}+{y}^{10}+O\left(11\right) \]
In [36]:
s1 := sx*sy
Out[36]:
\[ 1+\left(x+y\right)+\left({x}^{2}+y\, x+{y}^{2}\right)+\left({x}^{3}+y\, {x}^{2}+{y}^{2}\, x+{y}^{3}\right)+\left({x}^{4}+y\, {x}^{3}+{y}^{2}\, {x}^{2}+{y}^{3}\, x+{y}^{4}\right)+\left({x}^{5}+y\, {x}^{4}+{y}^{2}\, {x}^{3}+{y}^{3}\, {x}^{2}+{y}^{4}\, x+{y}^{5}\right)+\left({x}^{6}+y\, {x}^{5}+{y}^{2}\, {x}^{4}+{y}^{3}\, {x}^{3}+{y}^{4}\, {x}^{2}+{y}^{5}\, x+{y}^{6}\right)+\left({x}^{7}+y\, {x}^{6}+{y}^{2}\, {x}^{5}+{y}^{3}\, {x}^{4}+{y}^{4}\, {x}^{3}+{y}^{5}\, {x}^{2}+{y}^{6}\, x+{y}^{7}\right)+\left({x}^{8}+y\, {x}^{7}+{y}^{2}\, {x}^{6}+{y}^{3}\, {x}^{5}+{y}^{4}\, {x}^{4}+{y}^{5}\, {x}^{3}+{y}^{6}\, {x}^{2}+{y}^{7}\, x+{y}^{8}\right)+\left({x}^{9}+y\, {x}^{8}+{y}^{2}\, {x}^{7}+{y}^{3}\, {x}^{6}+{y}^{4}\, {x}^{5}+{y}^{5}\, {x}^{4}+{y}^{6}\, {x}^{3}+{y}^{7}\, {x}^{2}+{y}^{8}\, x+{y}^{9}\right)+\left({x}^{10}+y\, {x}^{9}+{y}^{2}\, {x}^{8}+{y}^{3}\, {x}^{7}+{y}^{4}\, {x}^{6}+{y}^{5}\, {x}^{5}+{y}^{6}\, {x}^{4}+{y}^{7}\, {x}^{3}+{y}^{8}\, {x}^{2}+{y}^{9}\, x+{y}^{10}\right)+O\left(11\right) \]
In [37]:
a: Symbol := 'a;
Out[37]:

We create a function that turns each monomial with exponent vector $l$ into a monomial with unknown coefficient $a(l)$.

In [38]:
fr(r:R):R ==
  rr: R := 0;
  e := enumerate()$V;
  for m in monomials r repeat
    l := degree(m, e); -- List Integer
    rr := rr + a(l)*m -- L is turned into List(OutputForm) here.
  rr
Function declaration fr : SparseMultivariatePolynomial(Expression(Integer),
OrderedVariableList([x,y])) -> SparseMultivariatePolynomial(Expression(
Integer),OrderedVariableList([x,y])) has been added to workspace.
Out[38]:
In [39]:
st1: Stream R := coefficients s1
Out[39]:
\[ \left[1, x+y, {x}^{2}+y\, x+{y}^{2}, {x}^{3}+y\, {x}^{2}+{y}^{2}\, x+{y}^{3}, {x}^{4}+y\, {x}^{3}+{y}^{2}\, {x}^{2}+{y}^{3}\, x+{y}^{4}, {x}^{5}+y\, {x}^{4}+{y}^{2}\, {x}^{3}+{y}^{3}\, {x}^{2}+{y}^{4}\, x+{y}^{5}, {x}^{6}+y\, {x}^{5}+{y}^{2}\, {x}^{4}+{y}^{3}\, {x}^{3}+{y}^{4}\, {x}^{2}+{y}^{5}\, x+{y}^{6}, {x}^{7}+y\, {x}^{6}+{y}^{2}\, {x}^{5}+{y}^{3}\, {x}^{4}+{y}^{4}\, {x}^{3}+{y}^{5}\, {x}^{2}+{y}^{6}\, x+{y}^{7}, {x}^{8}+y\, {x}^{7}+{y}^{2}\, {x}^{6}+{y}^{3}\, {x}^{5}+{y}^{4}\, {x}^{4}+{y}^{5}\, {x}^{3}+{y}^{6}\, {x}^{2}+{y}^{7}\, x+{y}^{8}, {x}^{9}+y\, {x}^{8}+{y}^{2}\, {x}^{7}+{y}^{3}\, {x}^{6}+{y}^{4}\, {x}^{5}+{y}^{5}\, {x}^{4}+{y}^{6}\, {x}^{3}+{y}^{7}\, {x}^{2}+{y}^{8}\, x+{y}^{9}, \ldots \right] \]
In [40]:
ast1: Stream R := map(fr, st1)
Compiling function fr with type SparseMultivariatePolynomial(Expression(
Integer),OrderedVariableList([x,y])) -> SparseMultivariatePolynomial(
Expression(Integer),OrderedVariableList([x,y])) 
Out[40]:
\[ \left[{a}_{0, 0}, {a}_{1, 0}\, x+{a}_{0, 1}\, y, {a}_{2, 0}\, {x}^{2}+{a}_{1, 1}\, y\, x+{a}_{0, 2}\, {y}^{2}, {a}_{3, 0}\, {x}^{3}+{a}_{2, 1}\, y\, {x}^{2}+{a}_{1, 2}\, {y}^{2}\, x+{a}_{0, 3}\, {y}^{3}, {a}_{4, 0}\, {x}^{4}+{a}_{3, 1}\, y\, {x}^{3}+{a}_{2, 2}\, {y}^{2}\, {x}^{2}+{a}_{1, 3}\, {y}^{3}\, x+{a}_{0, 4}\, {y}^{4}, {a}_{5, 0}\, {x}^{5}+{a}_{4, 1}\, y\, {x}^{4}+{a}_{3, 2}\, {y}^{2}\, {x}^{3}+{a}_{2, 3}\, {y}^{3}\, {x}^{2}+{a}_{1, 4}\, {y}^{4}\, x+{a}_{0, 5}\, {y}^{5}, {a}_{6, 0}\, {x}^{6}+{a}_{5, 1}\, y\, {x}^{5}+{a}_{4, 2}\, {y}^{2}\, {x}^{4}+{a}_{3, 3}\, {y}^{3}\, {x}^{3}+{a}_{2, 4}\, {y}^{4}\, {x}^{2}+{a}_{1, 5}\, {y}^{5}\, x+{a}_{0, 6}\, {y}^{6}, {a}_{7, 0}\, {x}^{7}+{a}_{6, 1}\, y\, {x}^{6}+{a}_{5, 2}\, {y}^{2}\, {x}^{5}+{a}_{4, 3}\, {y}^{3}\, {x}^{4}+{a}_{3, 4}\, {y}^{4}\, {x}^{3}+{a}_{2, 5}\, {y}^{5}\, {x}^{2}+{a}_{1, 6}\, {y}^{6}\, x+{a}_{0, 7}\, {y}^{7}, {a}_{8, 0}\, {x}^{8}+{a}_{7, 1}\, y\, {x}^{7}+{a}_{6, 2}\, {y}^{2}\, {x}^{6}+{a}_{5, 3}\, {y}^{3}\, {x}^{5}+{a}_{4, 4}\, {y}^{4}\, {x}^{4}+{a}_{3, 5}\, {y}^{5}\, {x}^{3}+{a}_{2, 6}\, {y}^{6}\, {x}^{2}+{a}_{1, 7}\, {y}^{7}\, x+{a}_{0, 8}\, {y}^{8}, {a}_{9, 0}\, {x}^{9}+{a}_{8, 1}\, y\, {x}^{8}+{a}_{7, 2}\, {y}^{2}\, {x}^{7}+{a}_{6, 3}\, {y}^{3}\, {x}^{6}+{a}_{5, 4}\, {y}^{4}\, {x}^{5}+{a}_{4, 5}\, {y}^{5}\, {x}^{4}+{a}_{3, 6}\, {y}^{6}\, {x}^{3}+{a}_{2, 7}\, {y}^{7}\, {x}^{2}+{a}_{1, 8}\, {y}^{8}\, x+{a}_{0, 9}\, {y}^{9}, \ldots \right] \]
In [41]:
a1: S := series ast1
Out[41]:
\[ {a}_{0, 0}+\left({a}_{1, 0}\, x+{a}_{0, 1}\, y\right)+\left({a}_{2, 0}\, {x}^{2}+{a}_{1, 1}\, y\, x+{a}_{0, 2}\, {y}^{2}\right)+\left({a}_{3, 0}\, {x}^{3}+{a}_{2, 1}\, y\, {x}^{2}+{a}_{1, 2}\, {y}^{2}\, x+{a}_{0, 3}\, {y}^{3}\right)+\left({a}_{4, 0}\, {x}^{4}+{a}_{3, 1}\, y\, {x}^{3}+{a}_{2, 2}\, {y}^{2}\, {x}^{2}+{a}_{1, 3}\, {y}^{3}\, x+{a}_{0, 4}\, {y}^{4}\right)+\left({a}_{5, 0}\, {x}^{5}+{a}_{4, 1}\, y\, {x}^{4}+{a}_{3, 2}\, {y}^{2}\, {x}^{3}+{a}_{2, 3}\, {y}^{3}\, {x}^{2}+{a}_{1, 4}\, {y}^{4}\, x+{a}_{0, 5}\, {y}^{5}\right)+\left({a}_{6, 0}\, {x}^{6}+{a}_{5, 1}\, y\, {x}^{5}+{a}_{4, 2}\, {y}^{2}\, {x}^{4}+{a}_{3, 3}\, {y}^{3}\, {x}^{3}+{a}_{2, 4}\, {y}^{4}\, {x}^{2}+{a}_{1, 5}\, {y}^{5}\, x+{a}_{0, 6}\, {y}^{6}\right)+\left({a}_{7, 0}\, {x}^{7}+{a}_{6, 1}\, y\, {x}^{6}+{a}_{5, 2}\, {y}^{2}\, {x}^{5}+{a}_{4, 3}\, {y}^{3}\, {x}^{4}+{a}_{3, 4}\, {y}^{4}\, {x}^{3}+{a}_{2, 5}\, {y}^{5}\, {x}^{2}+{a}_{1, 6}\, {y}^{6}\, x+{a}_{0, 7}\, {y}^{7}\right)+\left({a}_{8, 0}\, {x}^{8}+{a}_{7, 1}\, y\, {x}^{7}+{a}_{6, 2}\, {y}^{2}\, {x}^{6}+{a}_{5, 3}\, {y}^{3}\, {x}^{5}+{a}_{4, 4}\, {y}^{4}\, {x}^{4}+{a}_{3, 5}\, {y}^{5}\, {x}^{3}+{a}_{2, 6}\, {y}^{6}\, {x}^{2}+{a}_{1, 7}\, {y}^{7}\, x+{a}_{0, 8}\, {y}^{8}\right)+\left({a}_{9, 0}\, {x}^{9}+{a}_{8, 1}\, y\, {x}^{8}+{a}_{7, 2}\, {y}^{2}\, {x}^{7}+{a}_{6, 3}\, {y}^{3}\, {x}^{6}+{a}_{5, 4}\, {y}^{4}\, {x}^{5}+{a}_{4, 5}\, {y}^{5}\, {x}^{4}+{a}_{3, 6}\, {y}^{6}\, {x}^{3}+{a}_{2, 7}\, {y}^{7}\, {x}^{2}+{a}_{1, 8}\, {y}^{8}\, x+{a}_{0, 9}\, {y}^{9}\right)+\left({a}_{10, 0}\, {x}^{10}+{a}_{9, 1}\, y\, {x}^{9}+{a}_{8, 2}\, {y}^{2}\, {x}^{8}+{a}_{7, 3}\, {y}^{3}\, {x}^{7}+{a}_{6, 4}\, {y}^{4}\, {x}^{6}+{a}_{5, 5}\, {y}^{5}\, {x}^{5}+{a}_{4, 6}\, {y}^{6}\, {x}^{4}+{a}_{3, 7}\, {y}^{7}\, {x}^{3}+{a}_{2, 8}\, {y}^{8}\, {x}^{2}+{a}_{1, 9}\, {y}^{9}\, x+{a}_{0, 10}\, {y}^{10}\right)+O\left(11\right) \]
In [42]:
t:=(X+Y-1)*a1
Out[42]:
\[ -{a}_{0, 0}+\left(\left(-{a}_{1, 0}+{a}_{0, 0}\right)\, x+\left(-{a}_{0, 1}+{a}_{0, 0}\right)\, y\right)+\left(\left(-{a}_{2, 0}+{a}_{1, 0}\right)\, {x}^{2}+\left(-{a}_{1, 1}+{a}_{1, 0}+{a}_{0, 1}\right)\, y\, x+\left(-{a}_{0, 2}+{a}_{0, 1}\right)\, {y}^{2}\right)+\left(\left(-{a}_{3, 0}+{a}_{2, 0}\right)\, {x}^{3}+\left(-{a}_{2, 1}+{a}_{2, 0}+{a}_{1, 1}\right)\, y\, {x}^{2}+\left(-{a}_{1, 2}+{a}_{1, 1}+{a}_{0, 2}\right)\, {y}^{2}\, x+\left(-{a}_{0, 3}+{a}_{0, 2}\right)\, {y}^{3}\right)+\left(\left(-{a}_{4, 0}+{a}_{3, 0}\right)\, {x}^{4}+\left(-{a}_{3, 1}+{a}_{3, 0}+{a}_{2, 1}\right)\, y\, {x}^{3}+\left(-{a}_{2, 2}+{a}_{2, 1}+{a}_{1, 2}\right)\, {y}^{2}\, {x}^{2}+\left(-{a}_{1, 3}+{a}_{1, 2}+{a}_{0, 3}\right)\, {y}^{3}\, x+\left(-{a}_{0, 4}+{a}_{0, 3}\right)\, {y}^{4}\right)+\left(\left(-{a}_{5, 0}+{a}_{4, 0}\right)\, {x}^{5}+\left(-{a}_{4, 1}+{a}_{4, 0}+{a}_{3, 1}\right)\, y\, {x}^{4}+\left(-{a}_{3, 2}+{a}_{3, 1}+{a}_{2, 2}\right)\, {y}^{2}\, {x}^{3}+\left(-{a}_{2, 3}+{a}_{2, 2}+{a}_{1, 3}\right)\, {y}^{3}\, {x}^{2}+\left(-{a}_{1, 4}+{a}_{1, 3}+{a}_{0, 4}\right)\, {y}^{4}\, x+\left(-{a}_{0, 5}+{a}_{0, 4}\right)\, {y}^{5}\right)+\left(\left(-{a}_{6, 0}+{a}_{5, 0}\right)\, {x}^{6}+\left(-{a}_{5, 1}+{a}_{5, 0}+{a}_{4, 1}\right)\, y\, {x}^{5}+\left(-{a}_{4, 2}+{a}_{4, 1}+{a}_{3, 2}\right)\, {y}^{2}\, {x}^{4}+\left(-{a}_{3, 3}+{a}_{3, 2}+{a}_{2, 3}\right)\, {y}^{3}\, {x}^{3}+\left(-{a}_{2, 4}+{a}_{2, 3}+{a}_{1, 4}\right)\, {y}^{4}\, {x}^{2}+\left(-{a}_{1, 5}+{a}_{1, 4}+{a}_{0, 5}\right)\, {y}^{5}\, x+\left(-{a}_{0, 6}+{a}_{0, 5}\right)\, {y}^{6}\right)+\left(\left(-{a}_{7, 0}+{a}_{6, 0}\right)\, {x}^{7}+\left(-{a}_{6, 1}+{a}_{6, 0}+{a}_{5, 1}\right)\, y\, {x}^{6}+\left(-{a}_{5, 2}+{a}_{5, 1}+{a}_{4, 2}\right)\, {y}^{2}\, {x}^{5}+\left(-{a}_{4, 3}+{a}_{4, 2}+{a}_{3, 3}\right)\, {y}^{3}\, {x}^{4}+\left(-{a}_{3, 4}+{a}_{3, 3}+{a}_{2, 4}\right)\, {y}^{4}\, {x}^{3}+\left(-{a}_{2, 5}+{a}_{2, 4}+{a}_{1, 5}\right)\, {y}^{5}\, {x}^{2}+\left(-{a}_{1, 6}+{a}_{1, 5}+{a}_{0, 6}\right)\, {y}^{6}\, x+\left(-{a}_{0, 7}+{a}_{0, 6}\right)\, {y}^{7}\right)+\left(\left(-{a}_{8, 0}+{a}_{7, 0}\right)\, {x}^{8}+\left(-{a}_{7, 1}+{a}_{7, 0}+{a}_{6, 1}\right)\, y\, {x}^{7}+\left(-{a}_{6, 2}+{a}_{6, 1}+{a}_{5, 2}\right)\, {y}^{2}\, {x}^{6}+\left(-{a}_{5, 3}+{a}_{5, 2}+{a}_{4, 3}\right)\, {y}^{3}\, {x}^{5}+\left(-{a}_{4, 4}+{a}_{4, 3}+{a}_{3, 4}\right)\, {y}^{4}\, {x}^{4}+\left(-{a}_{3, 5}+{a}_{3, 4}+{a}_{2, 5}\right)\, {y}^{5}\, {x}^{3}+\left(-{a}_{2, 6}+{a}_{2, 5}+{a}_{1, 6}\right)\, {y}^{6}\, {x}^{2}+\left(-{a}_{1, 7}+{a}_{1, 6}+{a}_{0, 7}\right)\, {y}^{7}\, x+\left(-{a}_{0, 8}+{a}_{0, 7}\right)\, {y}^{8}\right)+\left(\left(-{a}_{9, 0}+{a}_{8, 0}\right)\, {x}^{9}+\left(-{a}_{8, 1}+{a}_{8, 0}+{a}_{7, 1}\right)\, y\, {x}^{8}+\left(-{a}_{7, 2}+{a}_{7, 1}+{a}_{6, 2}\right)\, {y}^{2}\, {x}^{7}+\left(-{a}_{6, 3}+{a}_{6, 2}+{a}_{5, 3}\right)\, {y}^{3}\, {x}^{6}+\left(-{a}_{5, 4}+{a}_{5, 3}+{a}_{4, 4}\right)\, {y}^{4}\, {x}^{5}+\left(-{a}_{4, 5}+{a}_{4, 4}+{a}_{3, 5}\right)\, {y}^{5}\, {x}^{4}+\left(-{a}_{3, 6}+{a}_{3, 5}+{a}_{2, 6}\right)\, {y}^{6}\, {x}^{3}+\left(-{a}_{2, 7}+{a}_{2, 6}+{a}_{1, 7}\right)\, {y}^{7}\, {x}^{2}+\left(-{a}_{1, 8}+{a}_{1, 7}+{a}_{0, 8}\right)\, {y}^{8}\, x+\left(-{a}_{0, 9}+{a}_{0, 8}\right)\, {y}^{9}\right)+\left(\left(-{a}_{10, 0}+{a}_{9, 0}\right)\, {x}^{10}+\left(-{a}_{9, 1}+{a}_{9, 0}+{a}_{8, 1}\right)\, y\, {x}^{9}+\left(-{a}_{8, 2}+{a}_{8, 1}+{a}_{7, 2}\right)\, {y}^{2}\, {x}^{8}+\left(-{a}_{7, 3}+{a}_{7, 2}+{a}_{6, 3}\right)\, {y}^{3}\, {x}^{7}+\left(-{a}_{6, 4}+{a}_{6, 3}+{a}_{5, 4}\right)\, {y}^{4}\, {x}^{6}+\left(-{a}_{5, 5}+{a}_{5, 4}+{a}_{4, 5}\right)\, {y}^{5}\, {x}^{5}+\left(-{a}_{4, 6}+{a}_{4, 5}+{a}_{3, 6}\right)\, {y}^{6}\, {x}^{4}+\left(-{a}_{3, 7}+{a}_{3, 6}+{a}_{2, 7}\right)\, {y}^{7}\, {x}^{3}+\left(-{a}_{2, 8}+{a}_{2, 7}+{a}_{1, 8}\right)\, {y}^{8}\, {x}^{2}+\left(-{a}_{1, 9}+{a}_{1, 8}+{a}_{0, 9}\right)\, {y}^{9}\, x+\left(-{a}_{0, 10}+{a}_{0, 9}\right)\, {y}^{10}\right)+O\left(11\right) \]
In [43]:
coefficient(t,3)
Out[43]:
\[ \left(-{a}_{3, 0}+{a}_{2, 0}\right)\, {x}^{3}+\left(-{a}_{2, 1}+{a}_{2, 0}+{a}_{1, 1}\right)\, y\, {x}^{2}+\left(-{a}_{1, 2}+{a}_{1, 1}+{a}_{0, 2}\right)\, {y}^{2}\, x+\left(-{a}_{0, 3}+{a}_{0, 2}\right)\, {y}^{3} \]
In [44]:
c := concat [coefficients coefficient(t, n) for n in 0..4]
Out[44]:
\[ \left[-{a}_{0, 0}, -{a}_{1, 0}+{a}_{0, 0}, -{a}_{0, 1}+{a}_{0, 0}, -{a}_{2, 0}+{a}_{1, 0}, -{a}_{1, 1}+{a}_{1, 0}+{a}_{0, 1}, -{a}_{0, 2}+{a}_{0, 1}, -{a}_{3, 0}+{a}_{2, 0}, -{a}_{2, 1}+{a}_{2, 0}+{a}_{1, 1}, -{a}_{1, 2}+{a}_{1, 1}+{a}_{0, 2}, -{a}_{0, 3}+{a}_{0, 2}, -{a}_{4, 0}+{a}_{3, 0}, -{a}_{3, 1}+{a}_{3, 0}+{a}_{2, 1}, -{a}_{2, 2}+{a}_{2, 1}+{a}_{1, 2}, -{a}_{1, 3}+{a}_{1, 2}+{a}_{0, 3}, -{a}_{0, 4}+{a}_{0, 3}\right] \]
In [45]:
variables first c
Out[45]:
\[ \left[{a}_{0, 0}\right] \]
In [46]:
vars: List Symbol := concat [variables z for z in c]
Out[46]:
\[ \left[{a}_{0, 0}, {a}_{0, 0}, {a}_{1, 0}, {a}_{0, 0}, {a}_{0, 1}, {a}_{1, 0}, {a}_{2, 0}, {a}_{0, 1}, {a}_{1, 0}, {a}_{1, 1}, {a}_{0, 1}, {a}_{0, 2}, {a}_{2, 0}, {a}_{3, 0}, {a}_{1, 1}, {a}_{2, 0}, {a}_{2, 1}, {a}_{0, 2}, {a}_{1, 1}, {a}_{1, 2}, {a}_{0, 2}, {a}_{0, 3}, {a}_{3, 0}, {a}_{4, 0}, {a}_{2, 1}, {a}_{3, 0}, {a}_{3, 1}, {a}_{1, 2}, {a}_{2, 1}, {a}_{2, 2}, {a}_{0, 3}, {a}_{1, 2}, {a}_{1, 3}, {a}_{0, 3}, {a}_{0, 4}\right] \]
In [47]:
v: List Symbol := [u for u in members set vars]
Out[47]:
\[ \left[{a}_{0, 0}, {a}_{0, 1}, {a}_{0, 2}, {a}_{0, 3}, {a}_{0, 4}, {a}_{1, 0}, {a}_{1, 1}, {a}_{1, 2}, {a}_{1, 3}, {a}_{2, 0}, {a}_{2, 1}, {a}_{2, 2}, {a}_{3, 0}, {a}_{3, 1}, {a}_{4, 0}\right] \]
In [48]:
es:=cons(a[0,0]-1, rest c)
Out[48]:
\[ \left[{a}_{0, 0}-1, -{a}_{1, 0}+{a}_{0, 0}, -{a}_{0, 1}+{a}_{0, 0}, -{a}_{2, 0}+{a}_{1, 0}, -{a}_{1, 1}+{a}_{1, 0}+{a}_{0, 1}, -{a}_{0, 2}+{a}_{0, 1}, -{a}_{3, 0}+{a}_{2, 0}, -{a}_{2, 1}+{a}_{2, 0}+{a}_{1, 1}, -{a}_{1, 2}+{a}_{1, 1}+{a}_{0, 2}, -{a}_{0, 3}+{a}_{0, 2}, -{a}_{4, 0}+{a}_{3, 0}, -{a}_{3, 1}+{a}_{3, 0}+{a}_{2, 1}, -{a}_{2, 2}+{a}_{2, 1}+{a}_{1, 2}, -{a}_{1, 3}+{a}_{1, 2}+{a}_{0, 3}, -{a}_{0, 4}+{a}_{0, 3}\right] \]
In [49]:
result:=solve([e=0 for e in es], v)
Out[49]:
\[ \left[\left[{a}_{0, 0}=1, {a}_{0, 1}=1, {a}_{0, 2}=1, {a}_{0, 3}=1, {a}_{0, 4}=1, {a}_{1, 0}=1, {a}_{1, 1}=2, {a}_{1, 2}=3, {a}_{1, 3}=4, {a}_{2, 0}=1, {a}_{2, 1}=3, {a}_{2, 2}=6, {a}_{3, 0}=1, {a}_{3, 1}=4, {a}_{4, 0}=1\right]\right] \]

Univariate Taylor series with unknown coefficients

In [52]:
a: Symbol := 'a
st: Stream E := [a[i::OutputForm] for i in 0..]

series(st)$SparseUnivariateTaylorSeries(E,'x,0)
Compiled code for fr has been cleared.
Out[52]:
\[ a \]
Out[52]:
\[ \left[{a}_{0}, {a}_{1}, {a}_{2}, {a}_{3}, {a}_{4}, {a}_{5}, {a}_{6}, {a}_{7}, {a}_{8}, {a}_{9}, \ldots \right] \]
Out[52]:
\[ {a}_{0}+{a}_{1}\, x+{a}_{2}\, {x}^{2}+{a}_{3}\, {x}^{3}+{a}_{4}\, {x}^{4}+{a}_{5}\, {x}^{5}+{a}_{6}\, {x}^{6}+{a}_{7}\, {x}^{7}+{a}_{8}\, {x}^{8}+{a}_{9}\, {x}^{9}+{a}_{10}\, {x}^{10}+O\left({x}^{11}\right) \]