TaylorSeries . jl : Taylor expansions in one and several variables in

The purpose of the TaylorSeries.jl package is to provide a framework to exploit Taylor polynomials in one and several variables in the Julia programming language (Bezanson, Edelman, Karpinski, & Shah, 2017). It can be thought of as providing a primitive CAS (computer algebra system), which works numerically and not symbolically. The package allows the user to define dense polynomials p(x) of one variable and p(x) of several variables with a specified maximum degree, and perform operations on them, including powers and composition, as well as series expansions for elementary functions of polynomials, for example exp[p(x)], where techniques of automatic differentiation are used (Haro, Canadell, Figueras, Luque, & Mondelo, 2016; Tucker, 2011). Differentiation and integration are also implemented.

Two basic immutable types are defined, Taylor1{T} and TaylorN{T}, which represent polynomials in one and several variables, respectively; the maximum degree is a field of the types.These types are parametrized by the type T of the polynomial coefficients; they essentially consist of one-dimensional arrays of coefficients, ordered by increasing degree.
In the case of TaylorN, the coefficients are HomogeneousPolynomials, which in turn are vectors of coefficients representing all monomials with a given number of variables and order (total degree), ordered lexicographically.Higher degree polynomials require more memory allocation, especially for several variables; while we have not extensively tested the limits of the degree of the polynomials that can be used, Taylor1 polynomials up to degree 80 and TaylorN polynomials up to degree 60 in 4 variables have been successfully used.Note that the current implementation of multi-variable series builds up extensive tables in memory which allow to speed up the index calculations.
TaylorSeries.jl is the main component of TaylorIntegration.jl (Pérez-Hernández & Benet, 2019), whose aim is to perform accurate integration of ODEs using the Taylor method, including jet transport techniques, where a small region around an initial condition is integrated.It is also a key component of TaylorModels.jl(Benet & Sanders, 2019), whose aim is to construct rigorous polynomial approximations of functions.

Examples
We present three examples to illustrate the use of TaylorSeries.jl.Other examples, as well as a detailed user guide, can be found in the documentation.

Hermite polynomials
As a first example we describe how to generate the Hermite polynomials ("physicist's" version) up to a given maximum order.Firstly we directly exploit the recurrence relation satisfied by the polynomials.
In [1]: using TaylorSeries displayBigO(false) function hermite_polynomials(::Type{T}, nmax::Int) where {T <: Integer} x = Taylor1(T, nmax) # Taylor variable H = fill(x, nmax + 1) # vector of Taylor series to be overwritten for n in 2:nmax # recursion relation for order n: The example above can be slightly modified to compute, for example, the 100th Hermite polynomial.In this case, the coefficients will be larger than 2 63 − 1, so the modular behavior, under overflow of the standard Int64 type, will not suffice.Rather, the polynomials should be generated with hermite_polynomials(BigInt, 100) to ensure the use of arbitrary-length integers.

Using a generating function
As a second example, we describe a numerical way of obtaining the Hermite polynomials from their generating function: the nth Hermite polynomial corresponds to the nth derivative of the function exp(2t x − t 2 ).This example shows that calculations are performed numerically and not symbolically, using TaylorSeries.jlas a polynomial manipulator; this is manifested by the fact that the last coefficient of HH( 6) is not identical to an integer.

Taylor method for integrating ordinary differential equations
As a final example, we give a simple implementation of Picard iteration to integrate an ordinary differential equation, which is equivalent to the Taylor method.
We consider the initial-value problem ẋ = x, with initial condition x(0) = 1.One step of the integration corresponds to constructing the Taylor series of the solution x(t) in powers of t: In Thus this Taylor expansion of order 20 around t 0 = 0 suffices to obtain the exact solution at t = 1, while the error at time t = 2 from the same expansion is 4.53 × 10 −14 .This indicates that a proper treatment should estimate the size of the required step that should be taken as a function of the solution.