login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

# Edit detail for TaylorSeries revision 7 of 7

 1 2 3 4 5 6 7 Editor: hemmecke Time: 2015/11/09 21:57:01 GMT+0 Note: remove "pretend" with FriCAS 1.2.7

added:

\begin{axiom}
)version
\end{axiom}

changed:
-    Unfortunately, there seems to be no way to easily create such series
-    without using "pretend".
We can create power series with
unknown coefficients.

changed:
-st1: Stream P := s1 pretend Stream P;
st1: Stream P := coefficients s1;

changed:
-a1: M := ast1 pretend M;
a1: M := series ast1;


## Example for multivariate Taylor series expansion

### Univariate TaylorSeries

FriCAS can deal with power series in a simple manner.

fricas
)version
Value = "FriCAS 1.3.1 compiled at Thu Feb 16 03:24:08 UTC 2017"

fricas
x:=taylor 'x
 (1)
Type: UnivariateTaylorSeries?(Expression(Integer),x,0)
fricas
sinh(x)
 (2)
Type: UnivariateTaylorSeries?(Expression(Integer),x,0)

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.

fricas
Z ==> Integer
Type: Void
fricas
Q ==> Fraction Z
Type: Void
fricas
Ux ==> UnivariateTaylorSeries(Q, 'x, 0)
Type: Void
fricas
ux: Ux := 'x
 (3)
Type: UnivariateTaylorSeries?(Fraction(Integer),x,0)
fricas
sinh(ux)
 (4)
Type: UnivariateTaylorSeries?(Fraction(Integer),x,0)

## Combination of univariate TaylorSeries

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

i.e., univariate power series in y with coefficients that are univariate power series in x that have rational coefficients.

fricas
Uy ==> UnivariateTaylorSeries(Q, 'y, 0)
Type: Void
fricas
uy: Uy := 'y
 (5)
Type: UnivariateTaylorSeries?(Fraction(Integer),y,0)
fricas
cosh(uy)
 (6)
Type: UnivariateTaylorSeries?(Fraction(Integer),y,0)
fricas
sinh(ux)*cosh(uy)
 (7)
Type: UnivariateTaylorSeries?(UnivariateTaylorSeries?(Fraction(Integer),x,0),y,0)

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 TaylorSeries 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 Q in infinitely many variables.

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

fricas
T ==> TaylorSeries Q
Type: Void
fricas
tx:T := 'x
 (8)
Type: TaylorSeries(Fraction(Integer))
fricas
ty:T := 'y
 (9)
Type: TaylorSeries(Fraction(Integer))
fricas
sinh(tx)*cosh(ty)
 (10)
Type: TaylorSeries(Fraction(Integer))

## 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.

fricas
vl: List Symbol := ['x, 'y]
 (11)
Type: List(Symbol)
fricas
V ==> OrderedVariableList vl
Type: Void
fricas
P ==> SparseMultivariatePolynomial(Q, V)
Type: Void
fricas
M ==> SparseMultivariateTaylorSeries(Q, V, P)
Type: Void
fricas
X: M := monomial(1$M, 'x, 1)  (12) Type: SparseMultivariateTaylorSeries(Fraction(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Fraction(Integer),OrderedVariableList([x,y]))) fricas Y: M := monomial(1$M, 'y, 1)
 (13)
Type: SparseMultivariateTaylorSeries(Fraction(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Fraction(Integer),OrderedVariableList([x,y])))
fricas
sinh(X)*cosh(Y)
 (14)
Type: SparseMultivariateTaylorSeries(Fraction(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Fraction(Integer),OrderedVariableList([x,y])))

## Multivariate Taylor series with unknown coefficients

We want to generate taylor series with unknown coefficients.

fricas
)clear completely
All user variables and function definitions have been cleared.
All )browse facility databases have been cleared.
Internally cached functions and constructors have been cleared.
)clear completely is finished.
vl: List Symbol := ['x, 'y];
Type: List(Symbol)
fricas
V ==> OrderedVariableList vl
Type: Void
fricas
Q ==> Expression Integer
Type: Void
fricas
P ==> SparseMultivariatePolynomial(Q, V)
Type: Void
fricas
M ==> SparseMultivariateTaylorSeries(Q, V, P)
Type: Void
fricas
X: M := monomial(1$M, 'x, 1)  (15) Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y]))) fricas Y: M := monomial(1$M, 'y, 1)
 (16)
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
sx:M := recip(1-X)
 (17)
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
sy:M := recip(1-Y)
 (18)
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
s1 := sx*sy
 (19)
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))

We can create power series with unknown coefficients.

fricas
a: Symbol := 'a;
Type: Symbol
fricas
fp(p:P):P == (pp:P := 0; e:=enumerate()\$V; for m in monomials p repeat (l:=degree(m,e); pp := pp + elt(a,l)*m);pp)
Function declaration fp : SparseMultivariatePolynomial(Expression(
Integer),OrderedVariableList([x,y])) ->
SparseMultivariatePolynomial(Expression(Integer),
OrderedVariableList([x,y])) has been added to workspace.
Type: Void
fricas
st1: Stream P := coefficients s1;
Type: Stream(SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
ast1: Stream P := map(fp, st1);
fricas
Compiling function fp with type SparseMultivariatePolynomial(
Expression(Integer),OrderedVariableList([x,y])) ->
SparseMultivariatePolynomial(Expression(Integer),
OrderedVariableList([x,y]))
Type: Stream(SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
a1: M := series ast1;
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
t:=(X+Y-1)*a1;
Type: SparseMultivariateTaylorSeries(Expression(Integer),OrderedVariableList([x,y]),SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y])))
fricas
coefficient(t,3)
 (20)
Type: SparseMultivariatePolynomial?(Expression(Integer),OrderedVariableList([x,y]))
fricas
c := concat [coefficients coefficient(t, n) for n in 0..4]
 (21)
Type: List(Expression(Integer))
fricas
variables first c
 (22)
Type: List(Symbol)
fricas
vars: List Symbol := concat [variables z for z in c]
 (23)
Type: List(Symbol)
fricas
v: List Symbol := [u for u in members set vars]
 (24)
Type: List(Symbol)
fricas
es:=cons(a[0,0]-1, rest c)
 (25)
Type: List(Expression(Integer))

Unfortunately, removing the semicolon from the end of the following command makes trouble for LaTeX.

fricas
result:=solve([e=0 for e in es], v);
Type: List(List(Equation(Expression(Integer))))

Bill Page: It seems to be a problem with encoding a list of lists.

fricas
for i in result repeat outputAsTex(i)
 (26)
Type: Void