Section8.9

]>
Book Contents Previous Section 8.8 Integration Next Section 8.10 Solution of Differential Equations Book Index

## 8.9 Working with Power Series

Axiom has very sophisticated facilities for working with power series series. power series

Infinite series are represented by a list of the coefficients that have already been determined, together with a function for computing the additional coefficients if needed.

The system command that determines how many terms of a series is displayed is )set streams calculate. For the purposes of this book, we have used this system command to display fewer than ten terms. set streams calculate Series can be created from expressions, from functions for the series coefficients, and from applications of operations on existing series. The most general function for creating a series is called series, although you can also use taylor, laurent and puiseux in situations where you know what kind of exponents are involved.

For information about solving differential equations in terms of power series, see ugxProblemDEQSeries .

### 8.9.1 Creation of Power Series

This is the easiest way to create a power series. This tells Axiom that x is to be treated as a power series, series:creating so functions of x are again power series.

x := series 'x

x

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

We didn't say anything about the coefficients of the power series, so the coefficients are general expressions over the integers. This allows us to introduce denominators, symbolic constants, and other variables as needed.

Here the coefficients are integers (note that the coefficients are the Fibonacci Fibonacci numbers numbers).

1/(1 - x - x**2)

1+x+2 x 2+3 x 3+5 x 4+8 x 5+13 x 6+21 x 7+34 x 8+55 x 9+89 x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

This series has coefficients that are rational numbers.

sin(x)

x-1 6 x 3+1 120 x 5-1 5040 x 7+1 362880 x 9-1 39916800 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

When you enter this expression you introduce the symbolic constants sin(1) and cos(1).

sin(1 + x)

sin(1)+cos(1)x-sin(1)2 x 2-cos(1)6 x 3+sin(1)24 x 4+cos(1)120 x 5-sin(1)720 x 6-cos(1)5040 x 7+sin(1)40320 x 8+cos(1)362880 x 9-sin(1)3628800 x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

When you enter the expression the variable a appears in the resulting series expansion.

sin(a * x)

a x-a 3 6 x 3+a 5 120 x 5-a 7 5040 x 7+a 9 362880 x 9-a 11 39916800 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

You can also convert an expression into a series expansion. This expression creates the series expansion of 1/log(y) about y=1. For details and more examples, see ugxProblemSeriesConversions .

series(1/log(y),y = 1)

(y-1)(-1)+1 2-1 12(y-1)+1 24(y-1)2-19 720(y-1)3+3 160(y-1)4-863 60480(y-1)5+275 24192(y-1)6-33953 3628800(y-1)7+8183 1036800(y-1)8-3250433 479001600(y-1)9+O((y-1)10)

Type: UnivariatePuiseuxSeries(Expression Integer,y,1)

You can create power series with more general coefficients. You normally accomplish this via a type declaration (see ugTypesDeclare ). See ugxProblemSeriesFunctions for some warnings about working with declared series.

We declare that y is a one-variable Taylor series series:Taylor (UTS is the abbreviation for UnivariateTaylorSeries) in the variable z with FLOAT (that is, floating-point) coefficients, centered about 0. Then, by assignment, we obtain the Taylor expansion of exp(z) with floating-point coefficients. UnivariateTaylorSeries

y : UTS(FLOAT,'z,0) := exp(z)

1. 0+z+0. 5 z 2+0. 1666666666 6666666667 z 3+0. 0416666666 6666666666 7 z 4+0. 0083333333 3333333333 34 z 5+0. 0013888888 8888888888 89 z 6+0. 0001984126 9841269841 27 z 7+0. 0000248015 8730158730 1587 z 8+0. 0000027557 3192239858 90653 z 9+0. 2755731922 3985890653 E-6 z 10+O(z 11)

Type: UnivariateTaylorSeries(Float,z,0.0)

You can also create a power series by giving an explicit formula for its n-th coefficient. For details and more examples, see ugxProblemSeriesFormula .

To create a series about w=0 whose n-th Taylor coefficient is 1/n!, you can evaluate this expression. This is the Taylor expansion of exp(w) at w=0.

series(1/factorial(n),n,w = 0)

1+w+1 2 w 2+1 6 w 3+1 24 w 4+1 120 w 5+1 720 w 6+1 5040 w 7+1 40320 w 8+1 362880 w 9+1 3628800 w 10+O(w 11)

Type: UnivariatePuiseuxSeries(Expression Integer,w,0)

### 8.9.2 Coefficients of Power Series

You can extract any coefficient from a power series---even one that hasn't been computed yet. This is possible because in Axiom, infinite series are represented by a list of the coefficients that have already been determined, together with a function for computing the additional coefficients. (This is known as lazy evaluation.) When you ask for a series:lazy evaluation coefficient that hasn't yet been computed, Axiom computes lazy evaluation whatever additional coefficients it needs and then stores them in the representation of the power series.

Here's an example of how to extract the coefficients of a power series. series:extracting coefficients

x := series(x)

x

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)
y := exp(x) * sin(x)

x+x 2+1 3 x 3-1 30 x 5-1 90 x 6-1 630 x 7+1 22680 x 9+1 113400 x 10+1 1247400 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

This coefficient is readily available.

coefficient(y,6)

-1 90

Type: Expression Integer

But let's get the fifteenth coefficient of y.

coefficient(y,15)

-1 10216206000

Type: Expression Integer

If you look at y then you see that the coefficients up to order 15 have all been computed.

y

x+x 2+1 3 x 3-1 30 x 5-1 90 x 6-1 630 x 7+1 22680 x 9+1 113400 x 10+1 1247400 x 11-1 97297200 x 13-1 681080400 x 14-1 10216206000 x 15+O(x 16)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

### 8.9.3 Power Series Arithmetic

You can manipulate power series using the usual arithmetic operations series:arithmetic +, -, *, and / (from UnivariatePuiseuxSeries)

The results of these operations are also power series.

x := series x

x

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)
(3 + x) / (1 + 7*x)

3-20 x+140 x 2-980 x 3+6860 x 4-48020 x 5+336140 x 6-2352980 x 7+16470860 x 8-115296020 x 9+807072140 x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

You can also compute f(x)**g(x), where f(x) and g(x) are two power series.

base := 1 / (1 - x)

1+x+x 2+x 3+x 4+x 5+x 6+x 7+x 8+x 9+x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)
expon := x * base

x+x 2+x 3+x 4+x 5+x 6+x 7+x 8+x 9+x 10+x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)
base ** expon

1+x 2+3 2 x 3+7 3 x 4+43 12 x 5+649 120 x 6+241 30 x 7+3706 315 x 8+85763 5040 x 9+245339 10080 x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

### 8.9.4 Functions on Power Series

Once you have created a power series, you can apply transcendental functions (for example, exp, log, sin, tan, cosh, etc.) to it.

To demonstrate this, we first create the power series expansion of the rational function

x 2 1-6 x+x 2

about x=0.

x := series 'x

x

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)
rat := x**2 / (1 - 6*x + x**2)

x 2+6 x 3+35 x 4+204 x 5+1189 x 6+6930 x 7+40391 x 8+235416 x 9+1372105 x 10+7997214 x 11+46611179 x 12+O(x 13)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

If you want to compute the series expansion of

sin(x 2 1-6 x+x 2)

you simply compute the sine of rat.

sin(rat)

x 2+6 x 3+35 x 4+204 x 5+7133 6 x 6+6927 x 7+80711 2 x 8+235068 x 9+164285281 120 x 10+31888513 4 x 11+371324777 8 x 12+O(x 13)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

Warning: the type of the coefficients of a power series may affect the kind of computations that you can do with that series. This can only happen when you have made a declaration to specify a series domain with a certain type of coefficient.

If you evaluate then you have declared that y is a one variable Taylor series series:Taylor (UTS is the abbreviation for UnivariateTaylorSeries) in the variable y with FRAC INT (that is, fractions of integer) coefficients, centered about 0.

y : UTS(FRAC INT,y,0) := y

y

Type: UnivariateTaylorSeries(Fraction Integer,y,0)

You can now compute certain power series in y, provided that these series have rational coefficients.

exp(y)

1+y+1 2 y 2+1 6 y 3+1 24 y 4+1 120 y 5+1 720 y 6+1 5040 y 7+1 40320 y 8+1 362880 y 9+1 3628800 y 10+O(y 11)

Type: UnivariateTaylorSeries(Fraction Integer,y,0)

You can get examples of such series by applying transcendental functions to series in y that have no constant terms.

tan(y**2)

y 2+1 3 y 6+2 15 y 10+O(y 11)

Type: UnivariateTaylorSeries(Fraction Integer,y,0)
cos(y + y**5)

1-1 2 y 2+1 24 y 4-721 720 y 6+6721 40320 y 8-1844641 3628800 y 10+O(y 11)

Type: UnivariateTaylorSeries(Fraction Integer,y,0)

Similarly, you can compute the logarithm of a power series with rational coefficients if the constant coefficient is 1.

log(1 + sin(y))

y-1 2 y 2+1 6 y 3-1 12 y 4+1 24 y 5-1 45 y 6+61 5040 y 7-17 2520 y 8+277 72576 y 9-31 14175 y 10+O(y 11)

Type: UnivariateTaylorSeries(Fraction Integer,y,0)

If you wanted to apply, say, the operation exp to a power series with a nonzero constant coefficient a 0, then the constant coefficient of the result would be e a 0, which is not a rational number. Therefore, evaluating exp(2+tan(y)) would generate an error message.

If you want to compute the Taylor expansion of exp(2+tan(y)), you must ensure that the coefficient domain has an operation exp defined for it. An example of such a domain is Expression Integer, the type of formal functional expressions over the integers.

When working with coefficients of this type,

z : UTS(EXPR INT,z,0) := z

z

Type: UnivariateTaylorSeries(Expression Integer,z,0)

this presents no problems.

exp(2 + tan(z))

e 2+e 2 z+e 2 2 z 2+e 2 2 z 3+3 e 2 8 z 4+37 e 2 120 z 5+59 e 2 240 z 6+137 e 2 720 z 7+871 e 2 5760 z 8+41641 e 2 362880 z 9+325249 e 2 3628800 z 10+O(z 11)

Type: UnivariateTaylorSeries(Expression Integer,z,0)

Another way to create Taylor series whose coefficients are expressions over the integers is to use taylor which works similarly to series:Taylor series.

This is equivalent to the previous computation, except that now we are using the variable w instead of z.

w := taylor 'w

w

Type: UnivariateTaylorSeries(Expression Integer,w,0)
exp(2 + tan(w))

e 2+e 2 w+e 2 2 w 2+e 2 2 w 3+3 e 2 8 w 4+37 e 2 120 w 5+59 e 2 240 w 6+137 e 2 720 w 7+871 e 2 5760 w 8+41641 e 2 362880 w 9+325249 e 2 3628800 w 10+O(w 11)

Type: UnivariateTaylorSeries(Expression Integer,w,0)

### 8.9.5 Converting to Power Series

The ExpressionToUnivariatePowerSeries package provides operations for computing series expansions of functions. ExpressionToUnivariatePowerSeries

Evaluate this to compute the Taylor expansion of sin x about series:Taylor x=0. The first argument, sin(x), specifies the function whose series expansion is to be computed and the second argument, x=0, specifies that the series is to be expanded in power of (x-0), that is, in power of x.

taylor(sin(x),x = 0)

x-1 6 x 3+1 120 x 5-1 5040 x 7+1 362880 x 9+O(x 11)

Type: UnivariateTaylorSeries(Expression Integer,x,0)

Here is the Taylor expansion of sin x about x=π 6:

taylor(sin(x),x = %pi/6)

1 2+3 2(x-π 6)-1 4(x-π 6)2-3 12(x-π 6)3+1 48(x-π 6)4+3 240(x-π 6)5-1 1440(x-π 6)6-3 10080(x-π 6)7+1 80640(x-π 6)8+3 725760(x-π 6)9-1 7257600(x-π 6)10+O((x-π 6)11)

Type: UnivariateTaylorSeries(Expression Integer,x,pi/6)

The function to be expanded into a series may have variables other than series:multiple variables the series variable.

For example, we may expand tan(x*y) as a Taylor series in x

taylor(tan(x*y),x = 0)

y x+y 3 3 x 3+2 y 5 15 x 5+17 y 7 315 x 7+62 y 9 2835 x 9+O(x 11)

Type: UnivariateTaylorSeries(Expression Integer,x,0)

or as a Taylor series in y.

taylor(tan(x*y),y = 0)

x y+x 3 3 y 3+2 x 5 15 y 5+17 x 7 315 y 7+62 x 9 2835 y 9+O(y 11)

Type: UnivariateTaylorSeries(Expression Integer,y,0)

A more interesting function is t e x t e t-1 When we expand this function as a Taylor series in t the n-th order coefficient is the n-th Bernoulli Bernoulli:polynomial polynomial polynomial:Bernoulli divided by n!.

bern := taylor(t*exp(x*t)/(exp(t) - 1),t = 0)

1+2 x-1 2 t+6 x 2-6 x+1 12 t 2+2 x 3-3 x 2+x 12 t 3+30 x 4-60 x 3+30 x 2-1 720 t 4+6 x 5-15 x 4+10 x 3-x 720 t 5+42 x 6-126 x 5+105 x 4-21 x 2+1 30240 t 6+6 x 7-21 x 6+21 x 5-7 x 3+x 30240 t 7+30 x 8-120 x 7+140 x 6-70 x 4+20 x 2-1 1209600 t 8+10 x 9-45 x 8+60 x 7-42 x 5+20 x 3-3 x 3628800 t 9+66 x 10-330 x 9+495 x 8-462 x 6+330 x 4-99 x 2+5 239500800 t 10+O(t 11)

Type: UnivariateTaylorSeries(Expression Integer,t,0)

Therefore, this and the next expression produce the same result.

factorial(6) * coefficient(bern,6)

42 x 6-126 x 5+105 x 4-21 x 2+1 42

Type: Expression Integer
bernoulliB(6,x)

x 6-3 x 5+5 2 x 4-1 2 x 2+1 42

Type: Polynomial Fraction Integer

Technically, a series with terms of negative degree is not considered to be a Taylor series, but, rather, a series:Laurent Laurent series. Laurent series If you try to compute a Taylor series expansion of x log x at x=1 via taylor(x/log(x),x=1) you get an error message. The reason is that the function has a pole at x=1, meaning that its series expansion about this point has terms of negative degree. A series with finitely many terms of negative degree is called a Laurent series.

You get the desired series expansion by issuing this.

laurent(x/log(x),x = 1)

(x-1)(-1)+3 2+5 12(x-1)-1 24(x-1)2+11 720(x-1)3-11 1440(x-1)4+271 60480(x-1)5-13 4480(x-1)6+7297 3628800(x-1)7-425 290304(x-1)8+530113 479001600(x-1)9+O((x-1)10)

Type: UnivariateLaurentSeries(Expression Integer,x,1)

Similarly, a series with terms of fractional degree is neither a Taylor series nor a Laurent series. Such a series is called a series:Puiseux Puiseux series. Puiseux series The expression laurent(sqrt(sec(x)),x=3*%pi/2) results in an error message because the series expansion about this point has terms of fractional degree.

However, this command produces what you want.

puiseux(sqrt(sec(x)),x = 3 * %pi/2)

(x-3 π 2)(-1 2)+1 12(x-3 π 2)3 2+1 160(x-3 π 2)7 2+O((x-3 π 2)5)

Type: UnivariatePuiseuxSeries(Expression Integer,x,(3*pi)/2)

Finally, consider the case of functions that do not have Puiseux expansions about certain points. An example of this is x x about x=0. puiseux(x**x, x=0) produces an error message because of the type of singularity of the function at x=0.

The general function series can be used in this case. Notice that the series returned is not, strictly speaking, a power series because of the log(x) in the expansion.

series(x**x,x=0)

1+log(x)x+log(x)2 2 x 2+log(x)3 6 x 3+log(x)4 24 x 4+log(x)5 120 x 5+log(x)6 720 x 6+log(x)7 5040 x 7+log(x)8 40320 x 8+log(x)9 362880 x 9+log(x)10 3628800 x 10+O(x 11)

Type: GeneralUnivariatePowerSeries(Expression Integer,x,0)

The operation series returns the most general type of infinite series. The user who is not interested in distinguishing between various types of infinite series may wish to use this operation exclusively.

### 8.9.6 Power Series from Formulas

The GenerateUnivariatePowerSeries package enables you to series:giving formula for coefficients create power series from explicit formulas for their n-th coefficients. In what follows, we construct series expansions for certain transcendental functions by giving formulas for their coefficients. You can also compute such series expansions directly simply by specifying the function and the point about which the series is to be expanded. GenerateUnivariatePowerSeries See ugxProblemSeriesConversions for more information.

Consider the Taylor expansion of e x series:Taylor about x=0:

e x=1+x+x 2 2+x 3 6+···=∑n=0∞x n n!

The n-th Taylor coefficient is 1/n!.

This is how you create this series in Axiom.

series(n +-> 1/factorial(n),x = 0)

1+x+1 2 x 2+1 6 x 3+1 24 x 4+1 120 x 5+1 720 x 6+1 5040 x 7+1 40320 x 8+1 362880 x 9+1 3628800 x 10+O(x 11)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

The first argument specifies a formula for the n-th coefficient by giving a function that maps n to 1/n!. The second argument specifies that the series is to be expanded in powers of (x-0), that is, in powers of x. Since we did not specify an initial degree, the first term in the series was the term of degree 0 (the constant term). Note that the formula was given as an anonymous function. These are discussed in ugUserAnon .

Consider the Taylor expansion of log x about x=1:

log(x)=(x-1)-(x-1)2 2+(x-1)3 3-···=∑n=1∞(-1)n-1(x-1)n n

If you were to evaluate the expression series(n+->(-1)**(n-1)/n, x=1) you would get an error message because Axiom would try to calculate a term of degree 0 and therefore divide by 0.

Instead, evaluate this. The third argument, 1.., indicates that only terms of degree n=1,... are to be computed.

series(n +-> (-1)**(n-1)/n,x = 1,1..)

(x-1)-1 2(x-1)2+1 3(x-1)3-1 4(x-1)4+1 5(x-1)5-1 6(x-1)6+1 7(x-1)7-1 8(x-1)8+1 9(x-1)9-1 10(x-1)10+1 11(x-1)11+O((x-1)12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,1)

Next consider the Taylor expansion of an odd function, say, sin(x):

sin(x)=x-x 3 3!+x 5 5!-···

Here every other coefficient is zero and we would like to give an explicit formula only for the odd Taylor coefficients.

This is one way to do it. The third argument, 1.., specifies that the first term to be computed is the term of degree 1. The fourth argument, 2, specifies that we increment by 2 to find the degrees of subsequent terms, that is, the next term is of degree 1+2, the next of degree 1+2+2, etc.

series(n +-> (-1)**((n-1)/2)/factorial(n),x = 0,1..,2)

x-1 6 x 3+1 120 x 5-1 5040 x 7+1 362880 x 9-1 39916800 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

The initial degree and the increment do not have to be integers. For example, this expression produces a series expansion of sin(x 1 3).

series(n +-> (-1)**((3*n-1)/2)/factorial(3*n),x = 0,1/3..,2/3)

x 1 3-1 6 x+1 120 x 5 3-1 5040 x 7 3+1 362880 x 3-1 39916800 x 11 3+O(x 4)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

While the increment must be positive, the initial degree may be negative. This yields the Laurent expansion of csc(x) at x=0. (bernoulli(numer(n+1)) is necessary because bernoulli takes integer arguments.)

cscx := series(n +-> (-1)**((n-1)/2) * 2 * (2**n-1) * bernoulli(numer(n+1)) / factorial(n+1), x=0, -1..,2)

x(-1)+1 6 x+7 360 x 3+31 15120 x 5+127 604800 x 7+73 3421440 x 9+O(x 10)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

Of course, the reciprocal of this power series is the Taylor expansion of sin(x).

1/cscx

x-1 6 x 3+1 120 x 5-1 5040 x 7+1 362880 x 9-1 39916800 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

As a final example,here is the Taylor expansion of asin(x) about x=0.

asinx := series(n +-> binomial(n-1,(n-1)/2)/(n*2**(n-1)),x=0,1..,2)

x+1 6 x 3+3 40 x 5+5 112 x 7+35 1152 x 9+63 2816 x 11+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

When we compute the sin of this series, we get x (in the sense that all higher terms computed so far are zero).

sin(asinx)

x+O(x 12)

Type: UnivariatePuiseuxSeries(Expression Integer,x,0)

Axiom isn't sufficiently ``symbolic'' in the sense we might wish. It is an open problem to decide that ``x'' is the only surviving term. Two attacks on the problem might be:

(1) Notice that all of the higher terms are identically zero but Axiom can't decide that from the information it knows. Presumably we could attack this problem by looking at the sin function as a taylor series around x=0 and seeing the term cancellation occur. This uses a term-difference mechanism.

(2) Notice that there is no way to decide that the stream for asinx is actually the definition of asin(x). But we could recognize that the stream for asin(x) has a generator term and so will a taylor series expansion of sin(x). From these two generators it may be possible in certain cases to decide that the application of one generator to the other will yield only ``x''. This trick involves finding the correct inverse for the stream functions. If we can find an inverse for the ``remaining tail'' of the stream we could conclude cancellation and thus turn an infinite stream into a finite object.

In general this is the zero-equivalence problem and is undecidable.

As we discussed in ugxProblemSeriesConversions , you can also use the operations taylor, laurent and puiseux instead of series if you know ahead of time what kind of exponents a series has. You can't go wrong using series, though.

### 8.9.7 Substituting Numerical Values in Power Series

Use evalevalUnivariatePowerSeriesCategory approximation to substitute a numerical value for a variable in series:numerical approximation a power series. For example, here's a way to obtain numerical approximations of %e from the Taylor series expansion of exp(x).

First you create the desired Taylor expansion.

f := taylor(exp(x))

1+x+1 2 x 2+1 6 x 3+1 24 x 4+1 120 x 5+1 720 x 6+1 5040 x 7+1 40320 x 8+1 362880 x 9+1 3628800 x 10+O(x 11)

Type: UnivariateTaylorSeries(Expression Integer,x,0)

Then you evaluate the series at the value 1. 0. The result is a sequence of the partial sums.

eval(f,1.0)

[1. 0, 2. 0, 2. 5, 2. 6666666666 666666667, 2. 7083333333 333333333,.2. 7166666666 666666667, 2. 7180555555 555555556, 2. 7182539682 53968254,.2. 7182787698 412698413, 2. 7182815255 731922399,…]

Type: Stream Expression Float

### 8.9.8 Example: Bernoulli Polynomials and Sums of Powers

Axiom provides operations for computing definite and summation:definite indefinite sums. summation:indefinite

You can compute the sum of the first ten fourth powers by evaluating this. This creates a list whose entries are m 4 as m ranges from 1 to 10, and then computes the sum of the entries of that list.

reduce(+,[m**4 for m in 1..10])

25333

Type: PositiveInteger

You can also compute a formula for the sum of the first k fourth powers, where k is an unspecified positive integer.

sum4 := sum(m**4, m = 1..k)

6 k 5+15 k 4+10 k 3-k 30

Type: Fraction Polynomial Integer

This formula is valid for any positive integer k. For instance, if we replace k by 10, summation:definite we obtain the number we computed earlier.

eval(sum4, k = 10)

25333

Type: Fraction Polynomial Integer

You can compute a formula for the sum of the first k n-th powers in a similar fashion. Just replace the 4 in the definition of sum4 by any expression not involving k. Axiom computes these formulas using Bernoulli polynomials; Bernoulli:polynomial we polynomial:Bernoulli use the rest of this section to describe this method.

First consider this function of t and x.

f := t*exp(x*t) / (exp(t) - 1)

t e(t x)e t-1

Type: Expression Integer

Since the expressions involved get quite large, we tell Axiom to show us only terms of degree up to 5.

)set streams calculate 5

set streams calculate

If we look at the Taylor expansion of f(x, t) about t=0, we see that the coefficients of the powers of t are polynomials in x.

ff := taylor(f,t = 0)

1+2 x-1 2 t+6 x 2-6 x+1 12 t 2+2 x 3-3 x 2+x 12 t 3+30 x 4-60 x 3+30 x 2-1 720 t 4+6 x 5-15 x 4+10 x 3-x 720 t 5+O(t 6)

Type: UnivariateTaylorSeries(Expression Integer,t,0)

In fact, the n-th coefficient in this series is essentially the n-th Bernoulli polynomial: the n-th coefficient of the series is 1 n! B n(x), where B n(x) is the n-th Bernoulli polynomial. Thus, to obtain the n-th Bernoulli polynomial, we multiply the n-th coefficient of the series ff by n!.

For example, the sixth Bernoulli polynomial is this.

factorial(6) * coefficient(ff,6)

42 x 6-126 x 5+105 x 4-21 x 2+1 42

Type: Expression Integer

We derive some properties of the function f(x, t). First we compute f(x+1, t)-f(x, t).

g := eval(f, x = x + 1) - f

t e(t x+t)-t e(t x)e t-1

Type: Expression Integer

If we normalize g, we see that it has a particularly simple form.

normalize(g)

t e(t x)

Type: Expression Integer

From this it follows that the n-th coefficient in the Taylor expansion of g(x, t) at t=0 is 1(n-1)!x n-1.

If you want to check this, evaluate the next expression.

taylor(g,t = 0)

t+x t 2+x 2 2 t 3+x 3 6 t 4+x 4 24 t 5+O(t 6)

Type: UnivariateTaylorSeries(Expression Integer,t,0)

However, since g(x, t)=f(x+1, t)-f(x, t) it follows that the n-th coefficient is 1 n!(B n(x+1)-B n(x)) Equating coefficients, we see that 1(n-1)!x n-1=1 n!(B n(x+1)-B n(x)) and, therefore, x n-1=1 n(B n(x+1)-B n(x))

Let's apply this formula repeatedly, letting x vary between two integers a and b, with a<b:

a n-1=1 n(B n(a+1)-B n(a))(a+1)n-1=1 n(B n(a+2)-B n(a+1))(a+2)n-1=1 n(B n(a+3)-B n(a+2))⋮(b-1)n-1=1 n(B n(b)-B n(b-1))b n-1=1 n(B n(b+1)-B n(b))

When we add these equations we find that the sum of the left-hand sides is the sum of the (n-1)st powers from a to b. The sum of the right-hand sides is a ``telescoping series.'' After cancellation, the sum is simply 1 n(B n(b+1)-B n(a))

Replacing n by n+1, we have shown that ∑m=a b m n=1 n+1(B n+1(b+1)-B n+1(a))

Let's use this to obtain the formula for the sum of fourth powers.

First we obtain the Bernoulli polynomial B 5.

B5 := factorial(5) * coefficient(ff,5)

6 x 5-15 x 4+10 x 3-x 6

Type: Expression Integer

To find the sum of the first k 4th powers, we multiply 1/5 by B 5(k+1)-B 5(1).

1/5 * (eval(B5, x = k + 1) - eval(B5, x = 1))

6 k 5+15 k 4+10 k 3-k 30

Type: Expression Integer

This is the same formula that we obtained via sum(m**4, m=1..k).

sum4

6 k 5+15 k 4+10 k 3-k 30

Type: Fraction Polynomial Integer

At this point you may want to do the same computation, but with an exponent other than 4. For example, you might try to find a formula for the sum of the first k 20th powers.

Book Contents Previous Section 8.8 Integration Next Section 8.10 Solution of Differential Equations Book Index