Up | Next | Prev | PrevTail | Tail |
This package carries out the Taylor expansion of an expression in one or more variables and efficient manipulation of the resulting Taylor series. Capabilities include basic operations (addition, subtraction, multiplication and division) and also application of certain algebraic and transcendental functions.
Author: Rainer Schöpf.
The most important operator is ‘TAYLOR’. It is used as follows:
where EXP is the expression to be expanded. It can be any REDUCE object, even an expression containing other Taylor kernels. VAR is the kernel with respect to which EXP is to be expanded. VAR0 denotes the point about which and ORDER the order up to which expansion is to take place. If more than one (VAR, VAR0, ORDER) triple is specified TAYLOR will expand its first argument independently with respect to each variable in turn. For example,
will calculate the Taylor expansion up to order X^{2} * Y ^{2}:
Note that once the expansion has been done it is not possible to calculate higher orders. Instead of a kernel, VAR may also be a list of kernels. In this case expansion will take place in a way so that the sum of the degrees of the kernels does not exceed ORDER. If VAR0 evaluates to the special identifier INFINITY, expansion is done in a series in 1/VAR instead of VAR.
The expansion is performed variable per variable, i.e. in the example above by first expanding exp(x^{2} + y^{2}) with respect to x and then expanding every coefficient with respect to y.
There are two extra operators to compute the Taylor expansions of implicit and inverse functions:
takes a function F depending on two variables VAR and DEPVAR and computes the Taylor series of the implicit function DEPVAR(VAR) given by the equation F(VAR,DEPVAR) = 0, around the point VAR0. (Violation of the necessary condition F(VAR0,DEPVAR0)=0 causes an error.) For example,
gives the output
takes a function F depending on VAR1 and computes the Taylor series of the inverse of F with respect to VAR2. For example,
yields
When a Taylor kernel is printed, only a certain number of (non-zero) coefficients are shown. If there are more, an expression of the form (n terms) is printed to indicate how many non-zero terms have been suppressed. The number of terms printed is given by the value of the shared algebraic variable TAYLORPRINTTERMS. Allowed values are integers and the special identifier ALL. The latter setting specifies that all terms are to be printed. The default setting is 5.
The PART operator can be used to extract subexpressions of a Taylor expansion in the usual way. All terms can be accessed, irregardless of the value of the variable TAYLORPRINTTERMS.
If the switch TAYLORKEEPORIGINAL is set to ON the original expression EXP is kept for later reference. It can be recovered by means of the operator
TAYLORORIGINAL(EXP:exprn):exprn
An error is signalled if EXP is not a Taylor kernel or if the original expression was not kept, i.e. if TAYLORKEEPORIGINAL was OFF during expansion. The template of a Taylor kernel, i.e. the list of all variables with respect to which expansion took place together with expansion point and order can be extracted using .
TAYLORTEMPLATE(EXP:exprn):list
This returns a list of lists with the three elements (VAR,VAR0,ORDER). As with TAYLORORIGINAL, an error is signalled if EXP is not a Taylor kernel.
The operator
TAYLORTOSTANDARD(EXP:exprn):exprn
converts all Taylor kernels in EXP into standard form and resimplifies the result.
The boolean operator
TAYLORSERIESP(EXP:exprn):boolean
may be used to determine if EXP is a Taylor kernel. (Note that this operator is subject to the same restrictions as, e.g., ORDP or NUMBERP, i.e. it may only be used in boolean expressions in IF or LET statements.
Finally there is
TAYLORCOMBINE(EXP:exprn):exprn
which tries to combine all Taylor kernels found in EXP into one. Operations currently possible are:
Application of unary operators like LOG and ATAN will nearly always succeed. For binary operations their arguments have to be Taylor kernels with the same template. This means that the expansion variable and the expansion point must match. Expansion order is not so important, different order usually means that one of them is truncated before doing the operation.
If TAYLORKEEPORIGINAL is set to ON and if all Taylor kernels in exp have their original expressions kept TAYLORCOMBINE will also combine these and store the result as the original expression of the resulting Taylor kernel. There is also the switch TAYLORAUTOEXPAND (see below).
There are a few restrictions to avoid mathematically undefined expressions: it is not possible to take the logarithm of a Taylor kernel which has no terms (i.e. is zero), or to divide by such a beast. There are some provisions made to detect singularities during expansion: poles that arise because the denominator has zeros at the expansion point are detected and properly treated, i.e. the Taylor kernel will start with a negative power. (This is accomplished by expanding numerator and denominator separately and combining the results.) Essential singularities of the known functions (see above) are handled correctly.
Differentiation of a Taylor expression is possible. If you differentiate with respect to one of the Taylor variables the order will decrease by one.
Substitution is a bit restricted: Taylor variables can only be replaced by other kernels. There is one exception to this rule: you can always substitute a Taylor variable by an expression that evaluates to a constant. Note that REDUCE will not always be able to determine that an expression is constant.
Only simple taylor kernels can be integrated. More complicated expressions that contain Taylor kernels as parts of themselves are automatically converted into a standard representation by means of the TAYLORTOSTANDARD operator. In this case a suitable warning is printed.
It is possible to revert a Taylor series of a function f, i.e., to compute the first terms of the expansion of the inverse of f from the expansion of f. This is done by the operator
TAYLORREVERT(EXP:exprn,OLDVAR:kernel, NEWVAR:kernel):exprn
EXP must evaluate to a Taylor kernel with OLDVAR being one of its expansion variables. Example:
gives
This package introduces a number of new switches:
TAYLOR should always detect non-analytical expressions in its first argument. As an example, consider the function xy∕(x + y) that is not analytical in the neighborhood of (x,y) = (0, 0): Trying to calculate
causes an error
Note that it is not generally possible to apply the standard REDUCE operators to a Taylor kernel. For example, PART, COEFF, or COEFFN cannot be used. Instead, the expression at hand has to be converted to standard form first using the TAYLORTOSTANDARD operator.
The error message can currently only appear when you try to calculate the inverse tangent or cotangent of a Taylor kernel that starts with a negative degree. The case of a logarithm of a Taylor kernel whose constant term is a negative real number is not caught since it is difficult to detect this in general.
At the moment there is only one REDUCE package that I know of: the truncated power series package by Alan Barnes and Julian Padget. In my opinion there are two major differences:
Up | Next | Prev | PrevTail | Front |