## #53 Cannot integrate 1/(1+x^n)

open
nobody
None
5
2009-11-16
2008-03-12
Ximin Luo
No

Maxima cannot integrate functions of the form

1/(1+x^n)

for n >= 7.

Mathematica is capable of this.

Maxima attempts the integration via an algorithm which seems to involve taking partial fractions. For example, if you try to integrate 1/(1+x^7) for example, Maxima gives:

log(1+x)/7 - integral(x^5-2*x^4+3*x^3-4*x^2+5*x-6)/(x^6-x^5+x^4-x^3+x^2-x+1) / 7

I'm guessing a different algorithm (such as that employed by Mathematica) is required to give a fully symbolic answer. For the record, the integral(1/(1+x^7)) is:

Log[1 + x]/7 - (Cos[Pi/7]*Log[1 + x^2 - 2*x*Cos[Pi/7]])/7 - (Cos[(3*Pi)/7]*Log[1 + x^2 - 2*x*Cos[(3*Pi)/7]])/7 - (Cos[(5*Pi)/7]*Log[1 + x^2 - 2*x*Cos[(5*Pi)/7]])/7 + (2*ArcTan[(x - Cos[Pi/7])*Csc[Pi/7]]* Sin[Pi/7])/7 + (2*ArcTan[(x - Cos[(3*Pi)/7])* Csc[(3*Pi)/7]]*Sin[(3*Pi)/7])/7 + (2*ArcTan[(x - Cos[(5*Pi)/7])* Csc[(5*Pi)/7]]*Sin[(5*Pi)/7])/7

----

Additionally, this also means that we can calculate the integral(that nasty rational function), by calculating

7 * ( log(1+x)/7 - integral(1/(1+x^7)) )

As a side note, Mathematica also cannot give integral(that nasty rational function) fully symbolically. Instead, it gives:

RootSum[1 - #1 + #1^2 - #1^3 + #1^4 - #1^5 + #1^6 & , (-6*Log[x - #1] + 5*Log[x - #1]*#1 - 4*Log[x - #1]*#1^2 + 3*Log[x - #1]* #1^3 - 2*Log[x - #1]*#1^4 + Log[x - #1]*#1^5)/(-1 + 2*#1 - 3*#1^2 + 4*#1^3 - 5*#1^4 + 6*#1^5) & ]

where RootSum[ f, form ] represents the sum of form[x] for all x that satisfy the polynomial equation f[x] == 0.

## Discussion

• Ximin Luo
2008-03-12

• labels: --> 840495

• Raymond Toy
2008-03-12

Logged In: YES
user_id=28849
Originator: NO

Maxima can't give an answer because it doesn't know the roots of (x^7+1)/(x+1).

If you set integrate_use_rootsof:true, then maxima can return an answer, but unless you can compute the roots of the above equation, it's probably not very helpful.

• Ximin Luo
2008-03-12

Logged In: YES
user_id=2003896
Originator: YES

The point is that Maxima does not NEED to know the roots of that equation. Sorry for making this unclear.

By doing the integral using a different algorithm which doesn't involve taking partial fractions, you can avoid the above, and get a purely symbolic integral, like Mathematic does.

• Raymond Toy
2008-03-13

Logged In: YES
user_id=28849
Originator: NO

Actually, the roots are obviously the seven roots of -1, which maxima does know, and it could have done the partial fraction expansion to find the value of the integral.

• Raymond Toy
2008-03-17

Logged In: YES
user_id=28849
Originator: NO

If you can, please describe how to integrate these without knowing the roots of the equation.

FWIW, maxima has a special function to integrate functions of the form f(x)/(a*x^n+b). (See enprog and eprog in sinint.lisp.) It only handles the cases of n = 4, 5, 6. And it does this by essentially doing a partial fraction expansion with hand-computed quadratic factors.

It seems feasible to extend this to any n.

• Raymond Toy
2008-03-17

Logged In: YES
user_id=28849
Originator: NO

If you can, please describe how to integrate these without knowing the roots of the equation.

FWIW, maxima has a special function to integrate functions of the form f(x)/(a*x^n+b). (See enprog and eprog in sinint.lisp.) It only handles the cases of n = 4, 5, 6. And it does this by essentially doing a partial fraction expansion with hand-computed quadratic factors.

It seems feasible to extend this to any n.

• Raymond Toy
2008-03-17

Logged In: YES
user_id=28849
Originator: NO

If you can, please describe how to integrate these without knowing the roots of the equation.

FWIW, maxima has a special function to integrate functions of the form f(x)/(a*x^n+b). (See enprog and eprog in sinint.lisp.) It only handles the cases of n = 4, 5, 6. And it does this by essentially doing a partial fraction expansion with hand-computed quadratic factors.

It seems feasible to extend this to any n.

• Ximin Luo
2008-03-17

Logged In: YES
user_id=2003896
Originator: YES

i don't know how to integrate these without knowing the roots of the equation; i thought mathematica was, because it could integrate 1/(1+x^n) without being able to integrate (that nasty rational
function). (and i thought algorithms do to this would be available somewhere else.)

also, i assumed maxima was already factorising the equation for arbitrarily large values of n.

but your approach seems feasible. what do you mean by hand-computed though? as in, numerically instead of algebraically? wouldn't that give imprecise answers?

• Raymond Toy
2008-03-17

Logged In: YES
user_id=28849
Originator: NO

By hand-computed, I mean someone wrote out the expansion of x^6+1 as (x^2+1)*(x^2+sqrt(3)*x+1)*(x^2-sqrt(3)*x+1).

I'm not sure maxima can figure that out itself.

For the general case x^n+c, we would need to write that as a product of quadratics (and maybe a linear term). Easy to do since we know the roots are, more or less, the n roots of unity. I think the results will be pretty ugly for n >= 7.

• Raymond Toy
2008-03-17

Logged In: YES
user_id=28849
Originator: NO

By hand-computed, I mean someone wrote out the expansion of x^6+1 as (x^2+1)*(x^2+sqrt(3)*x+1)*(x^2-sqrt(3)*x+1).

I'm not sure maxima can figure that out itself.

For the general case x^n+c, we would need to write that as a product of quadratics (and maybe a linear term). Easy to do since we know the roots are, more or less, the n roots of unity. I think the results will be pretty ugly for n >= 7.

• Robert Marik
2008-06-02

Logged In: YES
user_id=2033662
Originator: NO

This could be a similar problem (copied from Maxima discussion list)

Hello all, Maxima fails to evaluate integral of 1/(x^4+3*x^2+1).

Answers to this problem on Maxima list include:
-----------------------------------------------
BTW Maxima is able to factor x4+3*x2+1. To factor a polynomial over the
Gaussian integers, use "gfactor" instead of "factor":

gfactor(x4+3*x2+1) => (x2-%i*x+1)*(x2+%i*x+1)

itegrate doesn't handle 1/(x4+3*x2+1), but it does handle
1/gfactor(x4+3*x2+1).
-------------------------------------------------
Probably the integration code should be replaced. The commercial Macsyma
does the integral, which is kind of a mess, but
if you ev(%,numer) you get 0.72361 * atan(1.61804 * x) - 0.27639 *
atan(0.61803 * x)
--------------------------------------------------
The Horowitz method (1969) gives the rational part of the antiderivative of a rational function. The method for the logarithmic part is due to Trager (1976), I think. The residue method (at least for definite integration of rational functions) that Maxima might be using seems to be due to Wang (circa 1974). Maybe Maxima isn't using the best methods for
rational function integration?

• Dieter Kaiser
2009-11-16

As described in one of the postings the algorithm of Maxima handle the cases n=2, ..., 6. Furthermore, it is stated that it might be feasible to extend this.
I think this report is a feature request.

Setting the tracker to feature requests.

Dieter Kaiser

• Dieter Kaiser
2009-11-16

• labels: 840495 -->