diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index aecae993..cbb18992 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-02T20:48:09","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-22T15:11:21","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 32ac42d7..de13d82f 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,17 +1,17 @@ -API · TaylorSeries.jl

Library


Module

Types

TaylorSeries.Taylor1Type
Taylor1{T<:Number} <: AbstractSeries{T}

DataType for polynomial expansions in one independent variable.

Fields:

  • coeffs :: Array{T,1} Expansion coefficients; the $i$-th component is the coefficient of degree $i-1$ of the expansion.
  • order :: Int Maximum order (degree) of the polynomial.

Note that Taylor1 variables are callable. For more information, see evaluate.

source
TaylorSeries.HomogeneousPolynomialType
HomogeneousPolynomial{T<:Number} <: AbstractSeries{T}

DataType for homogeneous polynomials in many (>1) independent variables.

Fields:

  • coeffs :: Array{T,1} Expansion coefficients of the homogeneous

polynomial; the $i$-th component is related to a monomial, where the degrees of the independent variables are specified by coeff_table[order+1][i].

  • order :: Int order (degree) of the homogeneous polynomial.

Note that HomogeneousPolynomial variables are callable. For more information, see evaluate.

source
TaylorSeries.TaylorNType
TaylorN{T<:Number} <: AbstractSeries{T}

DataType for polynomial expansions in many (>1) independent variables.

Fields:

  • coeffs :: Array{HomogeneousPolynomial{T},1} Vector containing the

HomogeneousPolynomial entries. The $i$-th component corresponds to the homogeneous polynomial of degree $i-1$.

  • order :: Int maximum order of the polynomial expansion.

Note that TaylorN variables are callable. For more information, see evaluate.

source

Functions and methods

TaylorSeries.Taylor1Method
Taylor1([T::Type=Float64], order::Int)

Shortcut to define the independent variable of a Taylor1{T} polynomial of given order. The default type for T is Float64.

julia> Taylor1(16)
+API · TaylorSeries.jl

Library


Module

Types

TaylorSeries.Taylor1Type
Taylor1{T<:Number} <: AbstractSeries{T}

DataType for polynomial expansions in one independent variable.

Fields:

  • coeffs :: Array{T,1} Expansion coefficients; the $i$-th component is the coefficient of degree $i-1$ of the expansion.
  • order :: Int Maximum order (degree) of the polynomial.

Note that Taylor1 variables are callable. For more information, see evaluate.

source
TaylorSeries.HomogeneousPolynomialType
HomogeneousPolynomial{T<:Number} <: AbstractSeries{T}

DataType for homogeneous polynomials in many (>1) independent variables.

Fields:

  • coeffs :: Array{T,1} Expansion coefficients of the homogeneous

polynomial; the $i$-th component is related to a monomial, where the degrees of the independent variables are specified by coeff_table[order+1][i].

  • order :: Int order (degree) of the homogeneous polynomial.

Note that HomogeneousPolynomial variables are callable. For more information, see evaluate.

source
TaylorSeries.TaylorNType
TaylorN{T<:Number} <: AbstractSeries{T}

DataType for polynomial expansions in many (>1) independent variables.

Fields:

  • coeffs :: Array{HomogeneousPolynomial{T},1} Vector containing the

HomogeneousPolynomial entries. The $i$-th component corresponds to the homogeneous polynomial of degree $i-1$.

  • order :: Int maximum order of the polynomial expansion.

Note that TaylorN variables are callable. For more information, see evaluate.

source

Functions and methods

TaylorSeries.Taylor1Method
Taylor1([T::Type=Float64], order::Int)

Shortcut to define the independent variable of a Taylor1{T} polynomial of given order. The default type for T is Float64.

julia> Taylor1(16)
  1.0 t + 𝒪(t¹⁷)
 
 julia> Taylor1(Rational{Int}, 4)
- 1//1 t + 𝒪(t⁵)
source
TaylorSeries.HomogeneousPolynomialMethod
HomogeneousPolynomial([T::Type=Float64], nv::Int])

Shortcut to define the nv-th independent HomogeneousPolynomial{T}. The default type for T is Float64.

julia> HomogeneousPolynomial(1)
+ 1//1 t + 𝒪(t⁵)
source
TaylorSeries.HomogeneousPolynomialMethod
HomogeneousPolynomial([T::Type=Float64], nv::Int])

Shortcut to define the nv-th independent HomogeneousPolynomial{T}. The default type for T is Float64.

julia> HomogeneousPolynomial(1)
  1.0 x₁
 
 julia> HomogeneousPolynomial(Rational{Int}, 2)
- 1//1 x₂
source
TaylorSeries.TaylorNMethod
TaylorN([T::Type=Float64], nv::Int; [order::Int=get_order()])

Shortcut to define the nv-th independent TaylorN{T} variable as a polynomial. The order is defined through the keyword parameter order, whose default corresponds to get_order(). The default of type for T is Float64.

julia> TaylorN(1)
+ 1//1 x₂
source
TaylorSeries.TaylorNMethod
TaylorN([T::Type=Float64], nv::Int; [order::Int=get_order()])

Shortcut to define the nv-th independent TaylorN{T} variable as a polynomial. The order is defined through the keyword parameter order, whose default corresponds to get_order(). The default of type for T is Float64.

julia> TaylorN(1)
  1.0 x₁ + 𝒪(‖x‖⁷)
 
 julia> TaylorN(Rational{Int},2)
- 1//1 x₂ + 𝒪(‖x‖⁷)
source
TaylorSeries.set_variablesFunction
set_variables([T::Type], names::String; [order=get_order(), numvars=-1])

Return a TaylorN{T} vector with each entry representing an independent variable. names defines the output for each variable (separated by a space). The default type T is Float64, and the default for order is the one defined globally. Changing the order or numvars resets the hash_tables.

If numvars is not specified, it is inferred from names. If only one variable name is defined and numvars>1, it uses this name with subscripts for the different variables.

julia> set_variables(Int, "x y z", order=4)
+ 1//1 x₂ + 𝒪(‖x‖⁷)
source
TaylorSeries.set_variablesFunction
set_variables([T::Type], names::String; [order=get_order(), numvars=-1])

Return a TaylorN{T} vector with each entry representing an independent variable. names defines the output for each variable (separated by a space). The default type T is Float64, and the default for order is the one defined globally. Changing the order or numvars resets the hash_tables.

If numvars is not specified, it is inferred from names. If only one variable name is defined and numvars>1, it uses this name with subscripts for the different variables.

julia> set_variables(Int, "x y z", order=4)
 3-element Array{TaylorSeries.TaylorN{Int},1}:
   1 x + 𝒪(‖x‖⁵)
   1 y + 𝒪(‖x‖⁵)
@@ -25,57 +25,57 @@
 julia> set_variables("x", order=6, numvars=2)
 2-element Array{TaylorSeries.TaylorN{Float64},1}:
   1.0 x₁ + 𝒪(‖x‖⁷)
-  1.0 x₂ + 𝒪(‖x‖⁷)
source
TaylorSeries.get_variablesFunction
get_variables(T::Type, [order::Int=get_order()])

Return a TaylorN{T} vector with each entry representing an independent variable. It takes the default _params_TaylorN_ values if set_variables hasn't been changed with the exception that order can be explicitly established by the user without changing internal values for num_vars or variable_names. Omitting T defaults to Float64.

source
TaylorSeries.getcoeffFunction
getcoeff(a, n)

Return the coefficient of order n::Int of a a::Taylor1 polynomial.

source
getcoeff(a, v)

Return the coefficient of a::HomogeneousPolynomial, specified by v, which is a tuple (or vector) with the indices of the specific monomial.

source
getcoeff(a, v)

Return the coefficient of a::TaylorN, specified by v, which is a tuple (or vector) with the indices of the specific monomial.

source
TaylorSeries.evaluateFunction
evaluate(a, [dx])

Evaluate a Taylor1 polynomial using Horner's rule (hand coded). If dx is omitted, its value is considered as zero. Note that the syntax a(dx) is equivalent to evaluate(a,dx), and a() is equivalent to evaluate(a).

source
evaluate(x, δt)

Evaluates each element of x::AbstractArray{Taylor1{T}}, representing the dependent variables of an ODE, at time δt. Note that the syntax x(δt) is equivalent to evaluate(x, δt), and x() is equivalent to evaluate(x).

source
evaluate(a::Taylor1, x::Taylor1)

Substitute x::Taylor1 as independent variable in a a::Taylor1 polynomial. Note that the syntax a(x) is equivalent to evaluate(a, x).

source
evaluate(a, [vals])

Evaluate a HomogeneousPolynomial polynomial at vals. If vals is omitted, it's evaluated at zero. Note that the syntax a(vals) is equivalent to evaluate(a, vals); and a() is equivalent to evaluate(a).

source
evaluate(a, [vals]; sorting::Bool=true)

Evaluate the TaylorN polynomial a at vals. If vals is omitted, it's evaluated at zero. The keyword parameter sorting can be used to avoid sorting (in increasing order by abs2) the terms that are added.

Note that the syntax a(vals) is equivalent to evaluate(a, vals); and a() is equivalent to evaluate(a); use a(b::Bool, x) corresponds to evaluate(a, x, sorting=b).

source
TaylorSeries.evaluate!Function
evaluate!(x, δt, x0)

Evaluates each element of x::AbstractArray{Taylor1{T}}, representing the Taylor expansion for the dependent variables of an ODE at time δt. It updates the vector x0 with the computed values.

source
TaylorSeries.taylor_expandFunction
taylor_expand(f, x0; order)

Computes the Taylor expansion of the function f around the point x0.

If x0 is a scalar, a Taylor1 expansion will be returned. If x0 is a vector, a TaylorN expansion will be computed. If the dimension of x0 (length(x0)) is different from the variables set for TaylorN (get_numvars()), an AssertionError will be thrown.

source
TaylorSeries.differentiateFunction
differentiate(a)

Return the Taylor1 polynomial of the differential of a::Taylor1. The order of the result is a.order-1.

The function derivative is an exact synonym of differentiate.

source
differentiate(a, n)

Compute recursively the Taylor1 polynomial of the n-th derivative of a::Taylor1. The order of the result is a.order-n.

source
differentiate(n, a)

Return the value of the n-th differentiate of the polynomial a.

source
differentiate(a, r)

Partial differentiation of a::HomogeneousPolynomial series with respect to the r-th variable.

source
differentiate(a, r)

Partial differentiation of a::TaylorN series with respect to the r-th variable. The r-th variable may be also specified through its symbol.

source
differentiate(a::TaylorN{T}, ntup::NTuple{N,Int})

Return a TaylorN with the partial derivative of a defined by ntup::NTuple{N,Int}, where the first entry is the number of derivatives with respect to the first variable, the second is the number of derivatives with respect to the second, and so on.

source
differentiate(ntup::NTuple{N,Int}, a::TaylorN{T})

Returns the value of the coefficient of a specified by ntup::NTuple{N,Int}, multiplied by the corresponding factorials.

source
TaylorSeries.integrateFunction
integrate(a, [x])

Return the integral of a::Taylor1. The constant of integration (0-th order coefficient) is set to x, which is zero if omitted. Note that the order of the result is a.order+1.

source
integrate(a, r)

Integrate the a::HomogeneousPolynomial with respect to the r-th variable. The returned HomogeneousPolynomial has no added constant of integration. If the order of a corresponds to get_order(), a zero HomogeneousPolynomial of 0-th order is returned.

source
integrate(a, r, [x0])

Integrate the a::TaylorN series with respect to the r-th variable, where x0 the integration constant and must be independent of the r-th variable; if x0 is omitted, it is taken as zero.

source
TaylorSeries.jacobianFunction
    jacobian(vf)
-    jacobian(vf, [vals])

Compute the jacobian matrix of vf, a vector of TaylorN polynomials, evaluated at the vector vals. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.jacobian!Function
    jacobian!(jac, vf)
-    jacobian!(jac, vf, [vals])

Compute the jacobian matrix of vf, a vector of TaylorN polynomials evaluated at the vector vals, and write results to jac. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.hessianFunction
    hessian(f)
-    hessian(f, [vals])

Return the hessian matrix (jacobian of the gradient) of f::TaylorN, evaluated at the vector vals. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.hessian!Function
    hessian!(hes, f)
-    hessian!(hes, f, [vals])

Return the hessian matrix (jacobian of the gradient) of f::TaylorN, evaluated at the vector vals, and write results to hes. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.constant_termFunction
constant_term(a)

Return the constant value (zero order coefficient) for Taylor1 and TaylorN. The fallback behavior is to return a itself if a::Number, or a[1] when a::Vector.

source
TaylorSeries.linear_polynomialFunction
linear_polynomial(a)

Returns the linear part of a as a polynomial (Taylor1 or TaylorN), without the constant term. The fallback behavior is to return a itself.

source
TaylorSeries.inverseFunction
inverse(f)

Return the Taylor expansion of $f^{-1}(t)$, of order N = f.order, for f::Taylor1 polynomial, assuming the first coefficient of f is zero. Otherwise, a DomainError is thrown.

The algorithm implements Lagrange inversion at $t=0$ if $f(0)=0$:

\[\begin{equation*} + 1.0 x₂ + 𝒪(‖x‖⁷)

source
TaylorSeries.get_variablesFunction
get_variables(T::Type, [order::Int=get_order()])

Return a TaylorN{T} vector with each entry representing an independent variable. It takes the default _params_TaylorN_ values if set_variables hasn't been changed with the exception that order can be explicitly established by the user without changing internal values for num_vars or variable_names. Omitting T defaults to Float64.

source
TaylorSeries.getcoeffFunction
getcoeff(a, n)

Return the coefficient of order n::Int of a a::Taylor1 polynomial.

source
getcoeff(a, v)

Return the coefficient of a::HomogeneousPolynomial, specified by v, which is a tuple (or vector) with the indices of the specific monomial.

source
getcoeff(a, v)

Return the coefficient of a::TaylorN, specified by v, which is a tuple (or vector) with the indices of the specific monomial.

source
TaylorSeries.evaluateFunction
evaluate(a, [dx])

Evaluate a Taylor1 polynomial using Horner's rule (hand coded). If dx is omitted, its value is considered as zero. Note that the syntax a(dx) is equivalent to evaluate(a,dx), and a() is equivalent to evaluate(a).

source
evaluate(x, δt)

Evaluates each element of x::AbstractArray{Taylor1{T}}, representing the dependent variables of an ODE, at time δt. Note that the syntax x(δt) is equivalent to evaluate(x, δt), and x() is equivalent to evaluate(x).

source
evaluate(a::Taylor1, x::Taylor1)

Substitute x::Taylor1 as independent variable in a a::Taylor1 polynomial. Note that the syntax a(x) is equivalent to evaluate(a, x).

source
evaluate(a, [vals])

Evaluate a HomogeneousPolynomial polynomial at vals. If vals is omitted, it's evaluated at zero. Note that the syntax a(vals) is equivalent to evaluate(a, vals); and a() is equivalent to evaluate(a).

source
evaluate(a, [vals]; sorting::Bool=true)

Evaluate the TaylorN polynomial a at vals. If vals is omitted, it's evaluated at zero. The keyword parameter sorting can be used to avoid sorting (in increasing order by abs2) the terms that are added.

Note that the syntax a(vals) is equivalent to evaluate(a, vals); and a() is equivalent to evaluate(a); use a(b::Bool, x) corresponds to evaluate(a, x, sorting=b).

source
TaylorSeries.evaluate!Function
evaluate!(x, δt, x0)

Evaluates each element of x::AbstractArray{Taylor1{T}}, representing the Taylor expansion for the dependent variables of an ODE at time δt. It updates the vector x0 with the computed values.

source
TaylorSeries.taylor_expandFunction
taylor_expand(f, x0; order)

Computes the Taylor expansion of the function f around the point x0.

If x0 is a scalar, a Taylor1 expansion will be returned. If x0 is a vector, a TaylorN expansion will be computed. If the dimension of x0 (length(x0)) is different from the variables set for TaylorN (get_numvars()), an AssertionError will be thrown.

source
TaylorSeries.differentiateFunction
differentiate(a)

Return the Taylor1 polynomial of the differential of a::Taylor1. The order of the result is a.order-1.

The function derivative is an exact synonym of differentiate.

source
differentiate(a, n)

Compute recursively the Taylor1 polynomial of the n-th derivative of a::Taylor1. The order of the result is a.order-n.

source
differentiate(n, a)

Return the value of the n-th differentiate of the polynomial a.

source
differentiate(a, r)

Partial differentiation of a::HomogeneousPolynomial series with respect to the r-th variable.

source
differentiate(a, r)

Partial differentiation of a::TaylorN series with respect to the r-th variable. The r-th variable may be also specified through its symbol.

source
differentiate(a::TaylorN{T}, ntup::NTuple{N,Int})

Return a TaylorN with the partial derivative of a defined by ntup::NTuple{N,Int}, where the first entry is the number of derivatives with respect to the first variable, the second is the number of derivatives with respect to the second, and so on.

source
differentiate(ntup::NTuple{N,Int}, a::TaylorN{T})

Returns the value of the coefficient of a specified by ntup::NTuple{N,Int}, multiplied by the corresponding factorials.

source
TaylorSeries.integrateFunction
integrate(a, [x])

Return the integral of a::Taylor1. The constant of integration (0-th order coefficient) is set to x, which is zero if omitted. Note that the order of the result is a.order+1.

source
integrate(a, r)

Integrate the a::HomogeneousPolynomial with respect to the r-th variable. The returned HomogeneousPolynomial has no added constant of integration. If the order of a corresponds to get_order(), a zero HomogeneousPolynomial of 0-th order is returned.

source
integrate(a, r, [x0])

Integrate the a::TaylorN series with respect to the r-th variable, where x0 the integration constant and must be independent of the r-th variable; if x0 is omitted, it is taken as zero.

source
TaylorSeries.jacobianFunction
    jacobian(vf)
+    jacobian(vf, [vals])

Compute the jacobian matrix of vf, a vector of TaylorN polynomials, evaluated at the vector vals. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.jacobian!Function
    jacobian!(jac, vf)
+    jacobian!(jac, vf, [vals])

Compute the jacobian matrix of vf, a vector of TaylorN polynomials evaluated at the vector vals, and write results to jac. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.hessianFunction
    hessian(f)
+    hessian(f, [vals])

Return the hessian matrix (jacobian of the gradient) of f::TaylorN, evaluated at the vector vals. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.hessian!Function
    hessian!(hes, f)
+    hessian!(hes, f, [vals])

Return the hessian matrix (jacobian of the gradient) of f::TaylorN, evaluated at the vector vals, and write results to hes. If vals is omitted, it is evaluated at zero.

source
TaylorSeries.constant_termFunction
constant_term(a)

Return the constant value (zero order coefficient) for Taylor1 and TaylorN. The fallback behavior is to return a itself if a::Number, or a[1] when a::Vector.

source
TaylorSeries.linear_polynomialFunction
linear_polynomial(a)

Returns the linear part of a as a polynomial (Taylor1 or TaylorN), without the constant term. The fallback behavior is to return a itself.

source
TaylorSeries.inverseFunction
inverse(f)

Return the Taylor expansion of $f^{-1}(t)$, of order N = f.order, for f::Taylor1 polynomial, assuming the first coefficient of f is zero. Otherwise, a DomainError is thrown.

The algorithm implements Lagrange inversion at $t=0$ if $f(0)=0$:

\[\begin{equation*} f^{-1}(t) = \sum_{n=1}^{N} \frac{t^n}{n!} \left. \frac{{\rm d}^{n-1}}{{\rm d} z^{n-1}}\left(\frac{z}{f(z)}\right)^n \right\vert_{z=0}. -\end{equation*}\]

source
TaylorSeries.inverse_mapFunction
inverse_map(f)

Return the Taylor expansion of $f^{-1}(t)$, of order N = f.order, for Taylor1 or TaylorN polynomials, assuming the first coefficient of f is zero. Otherwise, a DomainError is thrown.

This method is based in the algorithm by M. Berz, Modern map methods in Particle Beam Physics, Academic Press (1999), Sect 2.3.1. See inverse (for f::Taylor1).

source
Base.absFunction
abs(a)

For a Real type returns a if constant_term(a) > 0 and -a if constant_term(a) < 0 for a <:Union{Taylor1,TaylorN}. For a Complex type, such as Taylor1{ComplexF64}, returns sqrt(real(a)^2 + imag(a)^2).

Notice that typeof(abs(a)) <: AbstractSeries and that for a Complex argument a Real type is returned (e.g. typeof(abs(a::Taylor1{ComplexF64})) == Taylor1{Float64}).

source
LinearAlgebra.normFunction
norm(x::AbstractSeries, p::Real)

Returns the p-norm of an x::AbstractSeries, defined by

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.inverse_mapFunction
inverse_map(f)

Return the Taylor expansion of $f^{-1}(t)$, of order N = f.order, for Taylor1 or TaylorN polynomials, assuming the first coefficient of f is zero. Otherwise, a DomainError is thrown.

This method is based in the algorithm by M. Berz, Modern map methods in Particle Beam Physics, Academic Press (1999), Sect 2.3.1. See inverse (for f::Taylor1).

source
Base.absFunction
abs(a)

For a Real type returns a if constant_term(a) > 0 and -a if constant_term(a) < 0 for a <:Union{Taylor1,TaylorN}. For a Complex type, such as Taylor1{ComplexF64}, returns sqrt(real(a)^2 + imag(a)^2).

Notice that typeof(abs(a)) <: AbstractSeries and that for a Complex argument a Real type is returned (e.g. typeof(abs(a::Taylor1{ComplexF64})) == Taylor1{Float64}).

source
LinearAlgebra.normFunction
norm(x::AbstractSeries, p::Real)

Returns the p-norm of an x::AbstractSeries, defined by

\[\begin{equation*} \left\Vert x \right\Vert_p = \left( \sum_k | x_k |^p \right)^{\frac{1}{p}}, -\end{equation*}\]

which returns a non-negative number.

source
Base.isapproxFunction
isapprox(x::AbstractSeries, y::AbstractSeries; rtol::Real=sqrt(eps), atol::Real=0, nans::Bool=false)

Inexact equality comparison between polynomials: returns true if norm(x-y,1) <= atol + rtol*max(norm(x,1), norm(y,1)), where x and y are polynomials. For more details, see Base.isapprox.

source
Base.islessFunction
isless(a::Taylor1{<:Real}, b::Real)
+\end{equation*}\]

which returns a non-negative number.

source
Base.isapproxFunction
isapprox(x::AbstractSeries, y::AbstractSeries; rtol::Real=sqrt(eps), atol::Real=0, nans::Bool=false)

Inexact equality comparison between polynomials: returns true if norm(x-y,1) <= atol + rtol*max(norm(x,1), norm(y,1)), where x and y are polynomials. For more details, see Base.isapprox.

source
Base.islessFunction
isless(a::Taylor1{<:Real}, b::Real)
 isless(a::TaylorN{<:Real}, b::Real)

Compute isless by comparing the constant_term(a) and b. If they are equal, returns a[nz] < 0, with nz the first non-zero coefficient after the constant term. This defines a total order.

For many variables, the ordering includes a lexicographical convention in order to be total. We have opted for the simplest one, where the larger variable appears before when the TaylorN variables are defined (e.g., through set_variables).

Refs:

  • M. Berz, AIP Conference Proceedings 177, 275 (1988); https://doi.org/10.1063/1.37800
  • M. Berz, "Automatic Differentiation as Nonarchimedean Analysis", Computer Arithmetic and Enclosure Methods, (1992), Elsevier, 439-450.

isless(a::Taylor1{<:Real}, b::Taylor1{<:Real})
-isless(a::TaylorN{<:Real}, b::Taylor1{<:Real})

Returns isless(a - b, zero(b)).

source
Base.isfiniteFunction
isfinite(x::AbstractSeries) -> Bool

Test whether the coefficients of the polynomial x are finite.

source
TaylorSeries.displayBigOFunction
displayBigO(d::Bool) --> nothing

Set/unset displaying of the big 𝒪 notation in the output of Taylor1 and TaylorN polynomials. The initial value is true.

source
TaylorSeries.use_show_defaultFunction
use_Base_show(d::Bool) --> nothing

Use Base.show_default method (default show method in Base), or a custom display. The initial value is false, so customized display is used.

source

Internals

TaylorSeries.ParamsTaylorNType
ParamsTaylorN

DataType holding the current parameters for TaylorN and HomogeneousPolynomial.

Fields:

  • order :: Int Order (degree) of the polynomials
  • num_vars :: Int Number of variables
  • variable_names :: Vector{String} Names of the variables
  • variable_symbols :: Vector{Symbol} Symbols of the variables

These parameters can be changed using set_variables

source
TaylorSeries._InternalMutFuncsType

_InternalMutFuncs

Contains parameters and expressions that allow a simple programmatic construction for calling the internal mutating functions.

source
TaylorSeries.generate_tablesFunction
generate_tables(num_vars, order)

Return the hash tables coeff_table, index_table, size_table and pos_table. Internally, these are treated as const.

Hash tables

coeff_table :: Array{Array{Array{Int,1},1},1}

The $i+1$-th component contains a vector with the vectors of all the possible combinations of monomials of a HomogeneousPolynomial of order $i$.

index_table :: Array{Array{Int,1},1}

The $i+1$-th component contains a vector of (hashed) indices that represent the distinct monomials of a HomogeneousPolynomial of order (degree) $i$.

size_table :: Array{Int,1}

The $i+1$-th component contains the number of distinct monomials of the HomogeneousPolynomial of order $i$, equivalent to length(coeff_table[i]).

pos_table :: Array{Dict{Int,Int},1}

The $i+1$-th component maps the hash index to the (lexicographic) position of the corresponding monomial in coeffs_table.

source
TaylorSeries.in_baseFunction
in_base(order, v)

Convert vector v of non-negative integers to base oorder, where oorder is the next odd integer of order.

source
TaylorSeries.make_inverse_dictFunction
make_inverse_dict(v)

Return a Dict with the enumeration of v: the elements of v point to the corresponding index.

It is used to construct pos_table from index_table.

source
TaylorSeries.resize_coeffs1!Function
resize_coeffs1!{T<Number}(coeffs::Array{T,1}, order::Int)

If the length of coeffs is smaller than order+1, it resizes coeffs appropriately filling it with zeros.

source
TaylorSeries.resize_coeffsHP!Function
resize_coeffsHP!{T<Number}(coeffs::Array{T,1}, order::Int)

If the length of coeffs is smaller than the number of coefficients correspondinf to order (given by size_table[order+1]), it resizes coeffs appropriately filling it with zeros.

source
LinearAlgebra.mul!Function
mul!(c, a, b, k::Int) --> nothing

Update the k-th expansion coefficient c[k] of c = a * b, where all c, a, and b are either Taylor1 or TaylorN. Note that for TaylorN the result of a * b is accumulated in c[k].

The coefficients are given by

\[c_k = \sum_{j=0}^k a_j b_{k-j}.\]

source
LinearAlgebra.mul!Method
mul!(c, a, b) --> nothing

Accumulates in c the result of a*b with minimum allocation. Arguments c, a and b are HomogeneousPolynomial.

source
TaylorSeries.mul_scalar!Method
mul_scalar!(c, scalar, a, b) --> nothing

Accumulates in c the result of scalar*a*b with minimum allocation. Arguments c, a and b are HomogeneousPolynomial; scalar is a NumberNotSeries.

source
TaylorSeries.div!Function
div!(c, a, b, k::Int)

Compute the k-th expansion coefficient c[k] of c = a / b, where all c, a and b are either Taylor1 or TaylorN.

The coefficients are given by

\[c_k = \frac{1}{b_0} \big(a_k - \sum_{j=0}^{k-1} c_j b_{k-j}\big).\]

For Taylor1 polynomials, a similar formula is implemented which exploits k_0, the order of the first non-zero coefficient of a.

source
TaylorSeries.pow!Function
pow!(c, a, r::Real, k::Int)

Update the k-th expansion coefficient c[k] of c = a^r, for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[c_k = \frac{1}{k a_0} \sum_{j=0}^{k-1} \big(r(k-j) -j\big)a_{k-j} c_j.\]

For Taylor1 polynomials, a similar formula is implemented which exploits k_0, the order of the first non-zero coefficient of a.

source
TaylorSeries.sqr!Function
sqr!(c, a, k::Int) --> nothing

Update the k-th expansion coefficient c[k] of c = a^2, for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} +isless(a::TaylorN{<:Real}, b::Taylor1{<:Real})

Returns isless(a - b, zero(b)).

source
Base.isfiniteFunction
isfinite(x::AbstractSeries) -> Bool

Test whether the coefficients of the polynomial x are finite.

source
TaylorSeries.displayBigOFunction
displayBigO(d::Bool) --> nothing

Set/unset displaying of the big 𝒪 notation in the output of Taylor1 and TaylorN polynomials. The initial value is true.

source
TaylorSeries.use_show_defaultFunction
use_Base_show(d::Bool) --> nothing

Use Base.show_default method (default show method in Base), or a custom display. The initial value is false, so customized display is used.

source

Internals

TaylorSeries.ParamsTaylorNType
ParamsTaylorN

DataType holding the current parameters for TaylorN and HomogeneousPolynomial.

Fields:

  • order :: Int Order (degree) of the polynomials
  • num_vars :: Int Number of variables
  • variable_names :: Vector{String} Names of the variables
  • variable_symbols :: Vector{Symbol} Symbols of the variables

These parameters can be changed using set_variables

source
TaylorSeries._InternalMutFuncsType

_InternalMutFuncs

Contains parameters and expressions that allow a simple programmatic construction for calling the internal mutating functions.

source
TaylorSeries.generate_tablesFunction
generate_tables(num_vars, order)

Return the hash tables coeff_table, index_table, size_table and pos_table. Internally, these are treated as const.

Hash tables

coeff_table :: Array{Array{Array{Int,1},1},1}

The $i+1$-th component contains a vector with the vectors of all the possible combinations of monomials of a HomogeneousPolynomial of order $i$.

index_table :: Array{Array{Int,1},1}

The $i+1$-th component contains a vector of (hashed) indices that represent the distinct monomials of a HomogeneousPolynomial of order (degree) $i$.

size_table :: Array{Int,1}

The $i+1$-th component contains the number of distinct monomials of the HomogeneousPolynomial of order $i$, equivalent to length(coeff_table[i]).

pos_table :: Array{Dict{Int,Int},1}

The $i+1$-th component maps the hash index to the (lexicographic) position of the corresponding monomial in coeffs_table.

source
TaylorSeries.in_baseFunction
in_base(order, v)

Convert vector v of non-negative integers to base oorder, where oorder is the next odd integer of order.

source
TaylorSeries.make_inverse_dictFunction
make_inverse_dict(v)

Return a Dict with the enumeration of v: the elements of v point to the corresponding index.

It is used to construct pos_table from index_table.

source
TaylorSeries.resize_coeffs1!Function
resize_coeffs1!{T<Number}(coeffs::Array{T,1}, order::Int)

If the length of coeffs is smaller than order+1, it resizes coeffs appropriately filling it with zeros.

source
TaylorSeries.resize_coeffsHP!Function
resize_coeffsHP!{T<Number}(coeffs::Array{T,1}, order::Int)

If the length of coeffs is smaller than the number of coefficients correspondinf to order (given by size_table[order+1]), it resizes coeffs appropriately filling it with zeros.

source
LinearAlgebra.mul!Function
mul!(c, a, b, k::Int) --> nothing

Update the k-th expansion coefficient c[k] of c = a * b, where all c, a, and b are either Taylor1 or TaylorN. Note that for TaylorN the result of a * b is accumulated in c[k].

The coefficients are given by

\[c_k = \sum_{j=0}^k a_j b_{k-j}.\]

source
LinearAlgebra.mul!Method
mul!(c, a, b) --> nothing

Accumulates in c the result of a*b with minimum allocation. Arguments c, a and b are HomogeneousPolynomial.

source
TaylorSeries.mul_scalar!Method
mul_scalar!(c, scalar, a, b) --> nothing

Accumulates in c the result of scalar*a*b with minimum allocation. Arguments c, a and b are HomogeneousPolynomial; scalar is a NumberNotSeries.

source
TaylorSeries.div!Function
div!(c, a, b, k::Int)

Compute the k-th expansion coefficient c[k] of c = a / b, where all c, a and b are either Taylor1 or TaylorN.

The coefficients are given by

\[c_k = \frac{1}{b_0} \big(a_k - \sum_{j=0}^{k-1} c_j b_{k-j}\big).\]

For Taylor1 polynomials, a similar formula is implemented which exploits k_0, the order of the first non-zero coefficient of a.

source
TaylorSeries.pow!Function
pow!(c, a, r::Real, k::Int)

Update the k-th expansion coefficient c[k] of c = a^r, for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[c_k = \frac{1}{k a_0} \sum_{j=0}^{k-1} \big(r(k-j) -j\big)a_{k-j} c_j.\]

For Taylor1 polynomials, a similar formula is implemented which exploits k_0, the order of the first non-zero coefficient of a.

source
TaylorSeries.sqr!Function
sqr!(c, a, k::Int) --> nothing

Update the k-th expansion coefficient c[k] of c = a^2, for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} c_k &= 2 \sum_{j=0}^{(k-1)/2} a_{k-j} a_j, \text{ if $k$ is odd,} \\ c_k &= 2 \sum_{j=0}^{(k-2)/2} a_{k-j} a_j + (a_{k/2})^2, \text{ if $k$ is even.} -\end{aligned}\]

source
TaylorSeries.accsqr!Function
accsqr!(c, a)

Returns c += a*a with no allocation; all parameters are HomogeneousPolynomial.

source
TaylorSeries.sqrt!Function
sqrt!(c, a, k::Int, k0::Int=0)

Compute the k-th expansion coefficient c[k] of c = sqrt(a) for bothc and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} +\end{aligned}\]

source
TaylorSeries.accsqr!Function
accsqr!(c, a)

Returns c += a*a with no allocation; all parameters are HomogeneousPolynomial.

source
TaylorSeries.sqrt!Function
sqrt!(c, a, k::Int, k0::Int=0)

Compute the k-th expansion coefficient c[k] of c = sqrt(a) for bothc and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} c_k &= \frac{1}{2 c_0} \big( a_k - 2 \sum_{j=1}^{(k-1)/2} c_{k-j}c_j\big), \text{ if $k$ is odd,} \\ c_k &= \frac{1}{2 c_0} \big( a_k - 2 \sum_{j=1}^{(k-2)/2} c_{k-j}c_j - (c_{k/2})^2\big), \text{ if $k$ is even.} -\end{aligned}\]

For Taylor1 polynomials, k0 is the order of the first non-zero coefficient, which must be even.

source
TaylorSeries.exp!Function
exp!(c, a, k) --> nothing

Update the k-th expansion coefficient c[k+1] of c = exp(a) for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{equation*} +\end{aligned}\]

For Taylor1 polynomials, k0 is the order of the first non-zero coefficient, which must be even.

source
TaylorSeries.exp!Function
exp!(c, a, k) --> nothing

Update the k-th expansion coefficient c[k+1] of c = exp(a) for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{equation*} c_k = \frac{1}{k} \sum_{j=0}^{k-1} (k-j) a_{k-j} c_j. -\end{equation*}\]

source
TaylorSeries.log!Function
log!(c, a, k) --> nothing

Update the k-th expansion coefficient c[k+1] of c = log(a) for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.log!Function
log!(c, a, k) --> nothing

Update the k-th expansion coefficient c[k+1] of c = log(a) for both c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{equation*} c_k = \frac{1}{a_0} \big(a_k - \frac{1}{k} \sum_{j=0}^{k-1} j a_{k-j} c_j \big). -\end{equation*}\]

source
TaylorSeries.sincos!Function
sincos!(s, c, a, k) --> nothing

Update the k-th expansion coefficients s[k+1] and c[k+1] of s = sin(a) and c = cos(a) simultaneously, for s, c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} +\end{equation*}\]

source
TaylorSeries.sincos!Function
sincos!(s, c, a, k) --> nothing

Update the k-th expansion coefficients s[k+1] and c[k+1] of s = sin(a) and c = cos(a) simultaneously, for s, c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} s_k &= \frac{1}{k}\sum_{j=0}^{k-1} (k-j) a_{k-j} c_j ,\\ c_k &= -\frac{1}{k}\sum_{j=0}^{k-1} (k-j) a_{k-j} s_j. -\end{aligned}\]

source
TaylorSeries.tan!Function
tan!(c, a, p, k::Int) --> nothing

Update the k-th expansion coefficients c[k+1] of c = tan(a), for c and a either Taylor1 or TaylorN; p = c^2 and is passed as an argument for efficiency.

The coefficients are given by

\[\begin{equation*} +\end{aligned}\]

source
TaylorSeries.tan!Function
tan!(c, a, p, k::Int) --> nothing

Update the k-th expansion coefficients c[k+1] of c = tan(a), for c and a either Taylor1 or TaylorN; p = c^2 and is passed as an argument for efficiency.

The coefficients are given by

\[\begin{equation*} c_k = a_k + \frac{1}{k} \sum_{j=0}^{k-1} (k-j) a_{k-j} p_j. -\end{equation*}\]

source
TaylorSeries.asin!Function
asin!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = asin(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.asin!Function
asin!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = asin(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} c_k = \frac{1}{ \sqrt{r_0} } \big( a_k - \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j \big). -\end{equation*}\]

source
TaylorSeries.acos!Function
acos!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = acos(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.acos!Function
acos!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = acos(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} c_k = - \frac{1}{ r_0 } \big( a_k - \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j \big). -\end{equation*}\]

source
TaylorSeries.atan!Function
atan!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = atan(a), for c and a either Taylor1 or TaylorN; r = 1+a^2 and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.atan!Function
atan!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = atan(a), for c and a either Taylor1 or TaylorN; r = 1+a^2 and is passed as an argument for efficiency.

\[\begin{equation*} c_k = \frac{1}{r_0}\big(a_k - \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j\big). -\end{equation*}\]

source
TaylorSeries.sinhcosh!Function
sinhcosh!(s, c, a, k)

Update the k-th expansion coefficients s[k+1] and c[k+1] of s = sinh(a) and c = cosh(a) simultaneously, for s, c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} +\end{equation*}\]

source
TaylorSeries.sinhcosh!Function
sinhcosh!(s, c, a, k)

Update the k-th expansion coefficients s[k+1] and c[k+1] of s = sinh(a) and c = cosh(a) simultaneously, for s, c and a either Taylor1 or TaylorN.

The coefficients are given by

\[\begin{aligned} s_k = \frac{1}{k} \sum_{j=0}^{k-1} (k-j) a_{k-j} c_j, \\ c_k = \frac{1}{k} \sum_{j=0}^{k-1} (k-j) a_{k-j} s_j. -\end{aligned}\]

source
TaylorSeries.tanh!Function
tanh!(c, a, p, k)

Update the k-th expansion coefficients c[k+1] of c = tanh(a), for c and a either Taylor1 or TaylorN; p = a^2 and is passed as an argument for efficiency.

\[\begin{equation*} +\end{aligned}\]

source
TaylorSeries.tanh!Function
tanh!(c, a, p, k)

Update the k-th expansion coefficients c[k+1] of c = tanh(a), for c and a either Taylor1 or TaylorN; p = a^2 and is passed as an argument for efficiency.

\[\begin{equation*} c_k = a_k - \frac{1}{k} \sum_{j=0}^{k-1} (k-j) a_{k-j} p_j. -\end{equation*}\]

source
TaylorSeries.asinh!Function
asinh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = asinh(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.asinh!Function
asinh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = asinh(a), for c and a either Taylor1 or TaylorN; r = sqrt(1-c^2) and is passed as an argument for efficiency.

\[\begin{equation*} c_k = \frac{1}{ \sqrt{r_0} } \big( a_k - \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j \big). -\end{equation*}\]

source
TaylorSeries.acosh!Function
acosh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = acosh(a), for c and a either Taylor1 or TaylorN; r = sqrt(c^2-1) and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.acosh!Function
acosh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = acosh(a), for c and a either Taylor1 or TaylorN; r = sqrt(c^2-1) and is passed as an argument for efficiency.

\[\begin{equation*} c_k = \frac{1}{ r_0 } \big( a_k - \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j \big). -\end{equation*}\]

source
TaylorSeries.atanh!Function
atanh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = atanh(a), for c and a either Taylor1 or TaylorN; r = 1-a^2 and is passed as an argument for efficiency.

\[\begin{equation*} +\end{equation*}\]

source
TaylorSeries.atanh!Function
atanh!(c, a, r, k)

Update the k-th expansion coefficients c[k+1] of c = atanh(a), for c and a either Taylor1 or TaylorN; r = 1-a^2 and is passed as an argument for efficiency.

\[\begin{equation*} c_k = \frac{1}{r_0}\big(a_k + \frac{1}{k} \sum_{j=1}^{k-1} j r_{k-j} c_j\big). -\end{equation*}\]

source
TaylorSeries.differentiate!Function
differentiate!(res, a) --> nothing

In-place version of differentiate. Compute the Taylor1 polynomial of the differential of a::Taylor1 and return it as res (order of res remains unchanged).

source
differentiate!(p, a, k) --> nothing

Update in-place the k-th expansion coefficient p[k] of p = differentiate(a) for both p and a Taylor1.

The coefficients are given by

\[p_k = (k+1) a_{k+1}.\]

source
TaylorSeries._dict_unary_opsConstant

_dict_binary_ops

Dict{Symbol, Array{Any,1}} with the information to construct the _InternalMutFuncs related to unary operations.

The keys correspond to the function symbols.

The arguments of the array are the function name (e.g. add!), a tuple with the function arguments, and an Expr with the calling pattern. The convention for the arguments of the functions and the calling pattern is to use :_res for the (mutated) result, :_arg1, for the required argument, possibly :_aux when there is an auxiliary expression needed, and :_k for the computed order of :_res. When an auxiliary expression is required, an Expr defining its calling pattern is added as the last entry of the vector.

source
TaylorSeries._dict_binary_callsConstant

_dict_binary_calls::Dict{Symbol, NTuple{2,Expr}}

Dictionary with the expressions that define the internal binary functions and the auxiliary functions, whenever they exist. The keys correspond to those functions, passed as symbols, with the defined internal mutating functions.

Evaluating the entries generates symbols that represent the actual calls to the internal mutating functions.

source
TaylorSeries._dict_unary_callsConstant

_dict_unary_calls::Dict{Symbol, NTuple{2,Expr}}

Dictionary with the expressions that define the internal unary functions and the auxiliary functions, whenever they exist. The keys correspond to those functions, passed as symbols, with the defined internal mutating functions.

Evaluating the entries generates expressions that represent the actual calls to the internal mutating functions.

source
TaylorSeries._dict_binary_opsConstant

_dict_binary_ops

Dict{Symbol, Array{Any,1}} with the information to construct the _InternalMutFuncs related to binary operations.

The keys correspond to the function symbols.

The arguments of the array are the function name (e.g. add!), a tuple with the function arguments, and an Expr with the calling pattern. The convention for the arguments of the functions and the calling pattern is to use :_res for the (mutated) result, :_arg1 and _arg2 for the required arguments, and :_k for the computed order of :_res.

source
TaylorSeries.@isonethreadMacro
@isonethread (expr)

Internal macro used to check the number of threads in use, to prevent a data race that modifies coeff_table when using differentiate or integrate; see https://github.com/JuliaDiff/TaylorSeries.jl/issues/318.

This macro is inspired by the macro @threaded; see https://github.com/trixi-framework/Trixi.jl/blob/main/src/auxiliary/auxiliary.jl; and https://github.com/trixi-framework/Trixi.jl/pull/426/files.

source

Index

+\end{equation*}\]

source
TaylorSeries.differentiate!Function
differentiate!(res, a) --> nothing

In-place version of differentiate. Compute the Taylor1 polynomial of the differential of a::Taylor1 and return it as res (order of res remains unchanged).

source
differentiate!(p, a, k) --> nothing

Update in-place the k-th expansion coefficient p[k] of p = differentiate(a) for both p and a Taylor1.

The coefficients are given by

\[p_k = (k+1) a_{k+1}.\]

source
TaylorSeries._internalmutfunc_callFunction
_internalmutfunc_call( fn :: _InternalMutFuncs )

Creates the appropriate call to the internal mutating function defined by the _InternalMutFuncs object. This is used to construct _dict_unary_calls and _dict_binary_calls. The call contains the prefix TaylorSeries..

source
TaylorSeries._dict_unary_opsConstant

_dict_binary_ops

Dict{Symbol, Array{Any,1}} with the information to construct the _InternalMutFuncs related to unary operations.

The keys correspond to the function symbols.

The arguments of the array are the function name (e.g. add!), a tuple with the function arguments, and an Expr with the calling pattern. The convention for the arguments of the functions and the calling pattern is to use :_res for the (mutated) result, :_arg1, for the required argument, possibly :_aux when there is an auxiliary expression needed, and :_k for the computed order of :_res. When an auxiliary expression is required, an Expr defining its calling pattern is added as the last entry of the vector.

source
TaylorSeries._dict_binary_callsConstant

_dict_binary_calls::Dict{Symbol, NTuple{2,Expr}}

Dictionary with the expressions that define the internal binary functions and the auxiliary functions, whenever they exist. The keys correspond to those functions, passed as symbols, with the defined internal mutating functions.

Evaluating the entries generates symbols that represent the actual calls to the internal mutating functions.

source
TaylorSeries._dict_unary_callsConstant

_dict_unary_calls::Dict{Symbol, NTuple{2,Expr}}

Dictionary with the expressions that define the internal unary functions and the auxiliary functions, whenever they exist. The keys correspond to those functions, passed as symbols, with the defined internal mutating functions.

Evaluating the entries generates expressions that represent the actual calls to the internal mutating functions.

source
TaylorSeries._dict_binary_opsConstant

_dict_binary_ops

Dict{Symbol, Array{Any,1}} with the information to construct the _InternalMutFuncs related to binary operations.

The keys correspond to the function symbols.

The arguments of the array are the function name (e.g. add!), a tuple with the function arguments, and an Expr with the calling pattern. The convention for the arguments of the functions and the calling pattern is to use :_res for the (mutated) result, :_arg1 and _arg2 for the required arguments, and :_k for the computed order of :_res.

source
TaylorSeries._populate_dicts!Function

_populate_dicts!()

Function that populates the internal dictionaries _dict_unary_calls and _dict_binary_calls

source
TaylorSeries.@isonethreadMacro
@isonethread (expr)

Internal macro used to check the number of threads in use, to prevent a data race that modifies coeff_table when using differentiate or integrate; see https://github.com/JuliaDiff/TaylorSeries.jl/issues/318.

This macro is inspired by the macro @threaded; see https://github.com/trixi-framework/Trixi.jl/blob/main/src/auxiliary/auxiliary.jl; and https://github.com/trixi-framework/Trixi.jl/pull/426/files.

source

Index

diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index b2bdd43e..82252a11 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -77,30 +77,35 @@ require(['jquery'], function($) { let timer = 0; var isExpanded = true; -$(document).on("click", ".docstring header", function () { - let articleToggleTitle = "Expand docstring"; - - debounce(() => { - if ($(this).siblings("section").is(":visible")) { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); - } else { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); +$(document).on( + "click", + ".docstring .docstring-article-toggle-button", + function () { + let articleToggleTitle = "Expand docstring"; + const parent = $(this).parent(); + + debounce(() => { + if (parent.siblings("section").is(":visible")) { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); + } else { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); - articleToggleTitle = "Collapse docstring"; - } + articleToggleTitle = "Collapse docstring"; + } - $(this) - .find(".docstring-article-toggle-button") - .prop("title", articleToggleTitle); - $(this).siblings("section").slideToggle(); - }); -}); + parent + .children(".docstring-article-toggle-button") + .prop("title", articleToggleTitle); + parent.siblings("section").slideToggle(); + }); + } +); $(document).on("click", ".docs-article-toggle-button", function (event) { let articleToggleTitle = "Expand docstring"; @@ -110,7 +115,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { debounce(() => { if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-down") .addClass("fa-chevron-right"); @@ -119,7 +124,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { $(".docstring section").slideUp(animationSpeed); } else { $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-right") .addClass("fa-chevron-down"); diff --git a/dev/background/index.html b/dev/background/index.html index 906cfe7e..2d0b53ee 100644 --- a/dev/background/index.html +++ b/dev/background/index.html @@ -15,4 +15,4 @@ s(t) = \sin(f(t)) , \qquad s_k = \frac{1}{k}\sum_{j=0}^{k-1} (k-j) \, f_{k-j} \, c_j; \\ c(t) = \cos(f(t)) , \qquad - c_k = -\frac{1}{k}\sum_{j=0}^{k-1} (k-j) \, f_{k-j} \, s_j.\]

The recursion relations for $s(t) = \sin\big(f(t)\big)$ and $c(t) = \cos\big(f(t)\big)$ depend on each other; this reflects the fact that they are solutions of a second-order differential equation.

All these relations hold for Taylor expansions in one and more independent variables; in the latter case, the Taylor coefficients $f_k$ are homogeneous polynomials of degree $k$; see [2].

References

[1] W. Tucker, Validated Numerics: A Short Introduction to Rigorous Computations, Princeton University Press (2011).

[2] A. Haro, Automatic differentiation methods in computational dynamical systems: Invariant manifolds and normal forms of vector fields at fixed points, preprint.

+ c_k = -\frac{1}{k}\sum_{j=0}^{k-1} (k-j) \, f_{k-j} \, s_j.\]

The recursion relations for $s(t) = \sin\big(f(t)\big)$ and $c(t) = \cos\big(f(t)\big)$ depend on each other; this reflects the fact that they are solutions of a second-order differential equation.

All these relations hold for Taylor expansions in one and more independent variables; in the latter case, the Taylor coefficients $f_k$ are homogeneous polynomials of degree $k$; see [2].

References

[1] W. Tucker, Validated Numerics: A Short Introduction to Rigorous Computations, Princeton University Press (2011).

[2] A. Haro, Automatic differentiation methods in computational dynamical systems: Invariant manifolds and normal forms of vector fields at fixed points, preprint.

diff --git a/dev/examples/index.html b/dev/examples/index.html index 6ad59cff..ca363000 100644 --- a/dev/examples/index.html +++ b/dev/examples/index.html @@ -36,9 +36,9 @@ s = one(T) + x + y + z + w s = s^degree s * ( s + one(T) ) - endfateman1 (generic function with 1 method)

(In the following lines, which are run when the documentation is built, by some reason the timing appears before the command executed.)

julia> @time fateman1(0);  0.039879 seconds (46.56 k allocations: 28.042 MiB, 70.29% compilation time)
julia> @time f1 = fateman1(20); 1.840439 seconds (1.22 k allocations: 31.153 MiB, 4.49% gc time)

Another implementation of the same, but exploiting optimizations related to ^2 yields:

julia> function fateman2(degree::Int)
+       endfateman1 (generic function with 1 method)

(In the following lines, which are run when the documentation is built, by some reason the timing appears before the command executed.)

julia> @time fateman1(0);  0.038289 seconds (46.56 k allocations: 28.038 MiB, 70.00% compilation time)
julia> @time f1 = fateman1(20); 1.810982 seconds (1.22 k allocations: 31.153 MiB, 4.22% gc time)

Another implementation of the same, but exploiting optimizations related to ^2 yields:

julia> function fateman2(degree::Int)
            T = Int128
            s = one(T) + x + y + z + w
            s = s^degree
            s^2 + s
-       endfateman2 (generic function with 1 method)
julia> fateman2(0);
julia> @time f2 = fateman2(20); # the timing appears above 0.893021 seconds (1.28 k allocations: 33.228 MiB, 0.22% gc time)

We note that the above functions use expansions in Int128. This is actually required, since some coefficients are larger than typemax(Int):

julia> getcoeff(f2, (1,6,7,20)) # coefficient of x y^6 z^7 w^{20}128358585324486316800
julia> ans > typemax(Int)true
julia> length(f2)41
julia> sum(TaylorSeries.size_table)135751

These examples show that fateman2 is nearly twice as fast as fateman1, and that the series has 135751 monomials in 4 variables.

Benchmarks

The functions described above have been compared against Mathematica v11.1. The relevant files used for benchmarking can be found here. Running on a MacPro with Intel-Xeon processors 2.7GHz, we obtain that Mathematica requires on average (5 runs) 3.075957 seconds for the computation, while for fateman1 and fateman2 above we obtain 2.15408 and 1.08337, respectively.

Then, with the current version of TaylorSeries.jl and using Julia v0.7.0, our implementation of fateman1 is about 30%-40% faster. (The original test by Fateman corresponds to fateman1 above, which avoids some optimizations related to squaring; the implementation in Mathematica is done such that this optimization does not occur.)

+ endfateman2 (generic function with 1 method)
julia> fateman2(0);
julia> @time f2 = fateman2(20); # the timing appears above 0.879664 seconds (1.28 k allocations: 33.228 MiB, 0.23% gc time)

We note that the above functions use expansions in Int128. This is actually required, since some coefficients are larger than typemax(Int):

julia> getcoeff(f2, (1,6,7,20)) # coefficient of x y^6 z^7 w^{20}128358585324486316800
julia> ans > typemax(Int)true
julia> length(f2)41
julia> sum(TaylorSeries.size_table)135751

These examples show that fateman2 is nearly twice as fast as fateman1, and that the series has 135751 monomials in 4 variables.

Benchmarks

The functions described above have been compared against Mathematica v11.1. The relevant files used for benchmarking can be found here. Running on a MacPro with Intel-Xeon processors 2.7GHz, we obtain that Mathematica requires on average (5 runs) 3.075957 seconds for the computation, while for fateman1 and fateman2 above we obtain 2.15408 and 1.08337, respectively.

Then, with the current version of TaylorSeries.jl and using Julia v0.7.0, our implementation of fateman1 is about 30%-40% faster. (The original test by Fateman corresponds to fateman1 above, which avoids some optimizations related to squaring; the implementation in Mathematica is done such that this optimization does not occur.)

diff --git a/dev/index.html b/dev/index.html index 960a6970..15943de3 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · TaylorSeries.jl

TaylorSeries.jl

A Julia package for Taylor expansions in one or more independent variables.


Authors

  • Luis Benet, Instituto de Ciencias Físicas, Universidad Nacional Autónoma de México (UNAM).
  • David P. Sanders, Facultad de Ciencias, Universidad Nacional Autónoma de México (UNAM).

Citing

If you find useful this package, please cite the paper:

Benet, L., & Sanders, D. P. (2019). TaylorSeries.jl: Taylor expansions in one and several variables in Julia. Journal of Open Source Software, 4(36), 1–4. https://doi.org/10.5281/zenodo.2601941

License

TaylorSeries is licensed under the MIT "Expat" license; see LICENSE for the full license text.

Installation

TaylorSeries.jl is a registered package, and is simply installed by running

pkg> add("TaylorSeries")

Acknowledgments

This project began (using Python) during a Masters' course in the postgraduate programs in Physics and in Mathematics at UNAM, during the second half of 2013. We thank the participants of the course for putting up with the half-baked material and contributing energy and ideas.

We acknowledge financial support from DGAPA-UNAM PAPIME grants PE-105911 and PE-107114, and DGAPA-PAPIIT grants IG-101113, IG-100616, IG-100819 and IG-101122. LB acknowledges support through a Cátedra Marcos Moshinsky (2013).

+Home · TaylorSeries.jl

TaylorSeries.jl

A Julia package for Taylor expansions in one or more independent variables.


Authors

  • Luis Benet, Instituto de Ciencias Físicas, Universidad Nacional Autónoma de México (UNAM).
  • David P. Sanders, Facultad de Ciencias, Universidad Nacional Autónoma de México (UNAM).

Citing

If you find useful this package, please cite the paper:

Benet, L., & Sanders, D. P. (2019). TaylorSeries.jl: Taylor expansions in one and several variables in Julia. Journal of Open Source Software, 4(36), 1–4. https://doi.org/10.5281/zenodo.2601941

License

TaylorSeries is licensed under the MIT "Expat" license; see LICENSE for the full license text.

Installation

TaylorSeries.jl is a registered package, and is simply installed by running

pkg> add("TaylorSeries")

Acknowledgments

This project began (using Python) during a Masters' course in the postgraduate programs in Physics and in Mathematics at UNAM, during the second half of 2013. We thank the participants of the course for putting up with the half-baked material and contributing energy and ideas.

We acknowledge financial support from DGAPA-UNAM PAPIME grants PE-105911 and PE-107114, and DGAPA-PAPIIT grants IG-101113, IG-100616, IG-100819 and IG-101122. LB acknowledges support through a Cátedra Marcos Moshinsky (2013).

diff --git a/dev/userguide/index.html b/dev/userguide/index.html index 5ec90e93..06ae637a 100644 --- a/dev/userguide/index.html +++ b/dev/userguide/index.html @@ -51,4 +51,4 @@ -26.0 20.0 20.0 -8.0

Other specific applications are described in the Examples.

Mixtures

As mentioned above, Taylor1{T}, HomogeneousPolynomial{T} and TaylorN{T} are parameterized structures such that T<:AbstractSeries, the latter is a subtype of Number. Then, we may actually define Taylor expansions in $N+1$ variables, where one of the variables (the Taylor1 variable) is somewhat special.

julia> x, y = set_variables("x y", order=3)2-element Vector{TaylorN{Float64}}:
   1.0 x + 𝒪(‖x‖⁴)
-  1.0 y + 𝒪(‖x‖⁴)
julia> t1N = Taylor1([zero(x), one(x)], 5) ( 1.0 + 𝒪(‖x‖⁴)) x + 𝒪(x⁶)

The last line defines a Taylor1{TaylorN{Float64}} variable, which is of order 5 in t and order 3 in x and y. Then, we can evaluate functions involving such polynomials:

julia> cos(2.1+x+t1N)  - 0.5048461045998576 - 0.8632093666488737 x + 0.2524230522999288 x² + 0.14386822777481229 x³ + 𝒪(‖x‖⁴) + ( - 0.8632093666488737 + 0.5048461045998576 x + 0.43160468332443686 x² - 0.0841410174333096 x³ + 𝒪(‖x‖⁴)) x + ( 0.2524230522999288 + 0.43160468332443686 x - 0.1262115261499644 x² - 0.07193411388740614 x³ + 𝒪(‖x‖⁴)) x² + ( 0.14386822777481229 - 0.0841410174333096 x - 0.07193411388740614 x² + 0.0140235029055516 x³ + 𝒪(‖x‖⁴)) x³ + ( - 0.0210352543583274 - 0.03596705694370307 x + 0.0105176271791637 x² + 0.005994509490617178 x³ + 𝒪(‖x‖⁴)) x⁴ + ( - 0.007193411388740615 + 0.00420705087166548 x + 0.0035967056943703073 x² - 0.00070117514527758 x³ + 𝒪(‖x‖⁴)) x⁵ + 𝒪(x⁶)

This kind of expansions are of interest when studying the dependence of parameters, for instance in the context of bifurcation theory or when considering the dependence of the solution of a differential equation on the initial conditions, around a given solution. In this case, x and y represent small variations around a given value of the parameters, or around some specific initial condition. Such constructions are exploited in the package TaylorIntegration.jl.

+ 1.0 y + 𝒪(‖x‖⁴)
julia> t1N = Taylor1([zero(x), one(x)], 5) ( 1.0 + 𝒪(‖x‖⁴)) x + 𝒪(x⁶)

The last line defines a Taylor1{TaylorN{Float64}} variable, which is of order 5 in t and order 3 in x and y. Then, we can evaluate functions involving such polynomials:

julia> cos(2.1+x+t1N)  - 0.5048461045998576 - 0.8632093666488737 x + 0.2524230522999288 x² + 0.14386822777481229 x³ + 𝒪(‖x‖⁴) + ( - 0.8632093666488737 + 0.5048461045998576 x + 0.43160468332443686 x² - 0.0841410174333096 x³ + 𝒪(‖x‖⁴)) x + ( 0.2524230522999288 + 0.43160468332443686 x - 0.1262115261499644 x² - 0.07193411388740614 x³ + 𝒪(‖x‖⁴)) x² + ( 0.14386822777481229 - 0.0841410174333096 x - 0.07193411388740614 x² + 0.0140235029055516 x³ + 𝒪(‖x‖⁴)) x³ + ( - 0.0210352543583274 - 0.03596705694370307 x + 0.0105176271791637 x² + 0.005994509490617178 x³ + 𝒪(‖x‖⁴)) x⁴ + ( - 0.007193411388740615 + 0.00420705087166548 x + 0.0035967056943703073 x² - 0.00070117514527758 x³ + 𝒪(‖x‖⁴)) x⁵ + 𝒪(x⁶)

This kind of expansions are of interest when studying the dependence of parameters, for instance in the context of bifurcation theory or when considering the dependence of the solution of a differential equation on the initial conditions, around a given solution. In this case, x and y represent small variations around a given value of the parameters, or around some specific initial condition. Such constructions are exploited in the package TaylorIntegration.jl.