ugly problems with trig integrals

Axel Vogt's picture
I was playing with a problem from the Maple NG, one can state it as
  
  Int( arccos(x) / ( 1+x^4) , x=0 .. 1)

Maple 11.02 gives a result, which numerical can not be valid.

Using real (!) partial fractions (Maple uses decomposition over the
complex, no?) I got a similar problem with denominator = parabola
(and continuity over the integration interval):

  Int( arccos(x) / (x^2 - x * 2^(1/2) + 1), x = 0 .. 1)

Some more and time-consuming consuming experiments reduces troubles
to the following example, where symbolics are disproven by numerics:

  Int( arccos(x)/(x - a), x = 0 .. 1), a = (1 - I ) / sqrt(2)

The interesting thing is: for the conjugate a it works.

And the only special situation I see: abs(zero(denom)) = 1.

Hope it is of interest, find a worksheet enclosed showing more details,
and would be happy about comments.

www.mapleprimes.com/files/102_ugly_trig_integrals.mws

 Edited: I shifted that thread into "Tips / Maple Techniques", it was in the wrong section

Comments

JacquesC's picture

Lovely

This is the type of bug which I most loved to hunt down and fix.  It is so full of fun and beautiful mathematics which one must do by hand (to double-check the same done in an automated fashion).  And it is often the case that the 'right' fix is really non-trivial.  All too often the place where things are obviously wrong are 'too late', as something subtle has already gone awry.  It never really felt like 'work' to fix such bugs! [Not to say that they were easy, in fact quite the opposite, but the challenge of fixing it, and doing it right, was highly rewarding]

an announcement?

This is a strange post to find in the "Announcements" section.

A representation

for the result of this integral is here:
                                                           2  1/2
          1/2         1/2             1/2         1/2    Pi  2
 1/16 Pi 2    ln(2 + 2   ) - 1/16 Pi 2    ln(2 - 2   ) + --------
                                                            16

+

infinity /   (-2 k - 2)        /                                    Pi k \\
 -----   |  2           (2 k)! |Pi - LerchPhi(-1, 1, 1/2 - k/2) cos(----)||
  \      |                     \                                     2   /|
   )     |- --------------------------------------------------------------|
  /      |                                  2     Pi k                    |
 -----   |                    (2 k + 1) (k!)  cos(----)                   |
 k = 0   \                                         2                      /

Note that in this series there is an issue with odd terms, but a numerical check (through a workaround) is OK. Details, sometime later.

Details for the ugly integral

The integrand

 f:=arccos(x)/(1+x^4); 

and its numerator, in particular, are smooth and bounded functions within the
interval [0,1]. So, for the evaluation of the integral J

j:=u->Int(u,x=0..1):
J:=j(f);

= Int(arccos(x)/(1+x^4),x = 0 .. 1);<br />

I will expand arccos(x) in a Taylor series and integrate term-by-term:

(fn,fd):=(numer,denom)(f):
fns:=convert(fn,FormalPowerSeries);
tk:=op([2,1],fns):

= 1/2*Pi+Sum(-(2*k)!*4^(-k)/k!^2/(2*k+1)*x^(2*k+1),k = 0 .. infinity);<br />

We get two pieces:

g1:=op(1,fns)/fd;
g2:=subsop(1=tk/fd,op(2,fns));

          Pi
g1 := ----------
              4
      2 (1 + x )

= Sum(-(2*k)!*4^(-k)/k!^2/(2*k+1)*x^(2*k+1)/(1+x^4),k = 0 .. infinity);<br />

So, the integral of g1 is:

J1:=j(g1);
J1v:=value(J1);

=<br />
1/16*Pi*2^(1/2)*ln(2+2^(1/2))-1/16*Pi*2^(1/2)*ln(2-2^(1/2))+1/16*Pi^2*2^(1/2);<br />

While the integral for the series becomes formally:

subsop(1=j(op(1,g2)),g2);
value(%):
J2s:=map(simplify,%);
sk:=op(1,J2s):

= sum(2^(-2*k-2)/(2*k+1)/k!^2*(2*k)!*(-Pi+LerchPhi(-1,1,1/2-1/2*k)*cos(1/2*Pi*k))/cos(1/2*Pi*k),k = 0 .. infinity);<br />

So, formally, J=J1v+J2s. Here, the terms with k odd are problematic. So, for a
numerical check of this result, I will sum even and odd terms separately.
First, the sum of the even terms:

eval(sk,k=2*m);
sm:=simplify(%) assuming m::posint;
Se:=Sum(sm,m=0..infinity);

=<br />
Sum(-1/4*1/(4*m+1)/(2*m)!^2*(4*m)!*16^(-m)*(Pi*(-1)^m-LerchPhi(-1,1,1/2-m)),m = 0 .. infinity);<br />

I have not got a closed form for this sum, but there is no problem to evaluate
it numerically.

Now, for the odd terms, evaluation of these terms produce error messages: "Error, (in
LerchPhi) numeric exception: division by zero". And 'limit', with factorials
replaced by 'GAMMA' calls:

skc:=convert(sk,GAMMA,factorial);

remains unevaluated (both "ordinary" or MultiSeries). Clearly there are
singularities, but it seems to me that they are "mild" in the sense that the limit
exist. Eg, a plot like

plot(skc,k=0..5);

shows a quite smooth curve. So, in the assumption that these limits exist, I
evaluate a numerical approximation of these limits as a mean of the value of
the terms with k shifted a bit below and a bit above, and add a number of
them:

Digits:=15:
So:=1/2*(add(evalf(eval(sk,k=2*i+1+10^(-6))),i=0..50)+
add(evalf(eval(sk,k=2*i+1-10^(-6))),i=0..50));

                        So := -.348302048743784e-1

Then, adding the numerical evaluation of these three terms:

evalf(J1v+Se)+So;
                        0.922570909713502

I get a result that compares quite well with:

evalf(J);
                          0.922548175702252

Clearly, there is a "delicate" balance between the value of 'Digits', the
magnitude of the "shift" and the number of terms in 'So'.

Axel Vogt's picture

liftable singularities

Thx, I was not able to prove that the singularities are liftable
(as the smooth plot suggests), sigh.

However modifying your approach (without further justification)
gives a result (where it is a matter of taste whether a series
over LerchPhi (=hypergeometrics) is really that better than some
integral). For this integrate the summands of your g2 formally
(the disturbing terms will not appear) and then apply the 
'Fundamental Theorem':

 'Sum(Int(-(2*k)!*4^(-k)/k!^2/(2*k+1)*x^(2*k+1)/(1+x^4),x ),
    k = 0 .. infinity)';
  value(%): 
  G:=subs(sum=Sum,%);

  'Int(1/2*Pi/(1+x^4),x = 0 .. 1)  +  eval(G,x=1) - eval(G,x=0)'; 
  
  value(%); evalf(%);


                                                            2  1/2
           1/2         1/2             1/2         1/2    Pi  2
  1/16 Pi 2    ln(2 + 2   ) - 1/16 Pi 2    ln(2 - 2   ) + -------- +
                                                             16

        /infinity                                                  \
        | -----   /   (-2 k - 2)                                  \|
        |  \      |  2           (2 k)! LerchPhi(-1, 1, k/2 + 1/2)||
        |   )     |- ---------------------------------------------||
        |  /      |                     2                         ||
        | -----   \                 (k!)  (2 k + 1)               /|
        \ k = 0                                                    /


                           0.92254817570232


My comparison

As I see it, the comparison has to be done between the fake primitive/antiderivative
function that Maple produces and this (apparently) correct primitive function:

<br />
1/16*Pi*2^(1/2)*ln((x^2+x*2^(1/2)+1)/(x^2-x*2^(1/2)+1))+1/8*Pi*2^(1/2)*arctan(x*2^(1/2)+1)+1/8*Pi*2^(1/2)*arctan(x*2^(1/2)-1)+Sum(-2^(-2*k-2)*(2*k)!/k!^2/(2*k+1)*x^(2*k+2)*LerchPhi(-x^4,1,1/2*k+1/2),k<br />
= 0 .. infinity);<br />

(using your G and Int(1/2*Pi/(1+x^4),x ) ).

And I do not know how much better is a 'dilog' than a 'LerchPhi'.

Axel Vogt's picture

a solution

even if my posting was more around to locate the error it is of interest to know the actual solution here is some related:

Moll et al "A formula for a quartic integral: a survey of old proofs and some new ones", front.math.ucdavis.edu/0707.2118

JacquesC's picture

A variant

The change of variable arccos(x) = t gives the simple-looking integral Int(t*sin(t)/(1+cos(t)^4),t=0..Pi/2) which Maple also gets wrong.  Is this the dilog expression that was referred to earlier?

dilogs

Either in this variable 't' or in the original form, and both definite or indefinite integral, Maple wrong answers have the same structure: sums over 'RootOf' of 'dilog' function calls.

To my eyes, they look much more messy than the series form. And 'dilog' is not less "abstract" than 'LerchPhi'. 

 

Axel Vogt's picture

Well, that was the original task

k, from which I took as motivation:

groups.google.de/group/comp.soft-sys.math.maple/browse_thread/thread/c71f510677102dca/
where MMA is said to give an answer, hypergeom([1/4, 1/2, 1, 1], [3/4, 5/4, 5/4], -1) for mine,
just by symmetry, but a 4F3 hypergeometric is not quite nice, even if it is not a series in
special functions (ok, it may be written as such I think).

Herman Rubin suggests to use u=x and dv=sin(x)/(1+(cos(x))^4)dx with integration by parts to
solve Int(x*sin(x)/(1+(cos(x))^4),x=0..Pi/2).

This - more or less - with (real) partial fraction leads to similar questions/problems as we
looked at the thread http://www.mapleprimes.com/forum/mapleintegrationerror0, where the task
was integrating log ( polynom( cos(t) ) ) over 0 ... Pi.

I think the latter always cam be done in Maple, if the polynom has conjugated complex roots
(treating them by hand) and that should be the case for the problem here.

However that seems not to work for degree=1, i.e. for Int(ln(cos(t)-a),t = 0 .. 1/2*Pi) and
'my' eval(%, a = (1 - I ) / sqrt(2)).

The translation is as follows:
  
  Int( arccos(x)/(x - a), x = 0 .. 1 ) =                 # x=arccos(t) 
= Int( t*sin(t)/(cos(t)-a), t = 0 .. 1/2*Pi ) =          # using Parts(%,t)
= Int( ln(cos(t)-a),t = 0 .. 1/2*Pi ) - 1/2*Pi*ln(-a)

For our a = (1 - I ) / sqrt(2)) Maple 11.2 returns the last integral unevaluated, numerical
it is -0.41481325995246+2.5875517785926*I.

However one *can* do it symbolical as below, where it is nicer to have it up to Pi (not Pi/2)
where M11 also would return unevaluated:

  Int(ln((cos(t)-a)),t=0..Pi);
  ``=PDEtools[dchange](t=arccos(x),%,[x]);
  ``=value(rhs(%)):
  simplify(%); 
  eval(%, a = (1 - I ) / sqrt(2)); evalf(%);

                          Pi
                         /
                        |
                        |    ln(cos(t) - a) dt
                        |
                       /
                         0

                              1
                             /
                            |    ln(x - a)
                         =  |   ----------- dx
                            |         2 1/2
                           /    (1 - x )
                             -1

                   /                        /      2\1/2 \
                   |                        |-1 + a |    |
              = Pi |ln(-a) - ln(2) + ln(1 + |-------|   )|
                   |                        |   2   |    |
                   \                        \  a    /    /


                 = 0.22348749526260 + 6.7313498260590 I

That is the same value as a pure numerical quadrature gives.

Doing it for Pi/2 would show hypergeometrics 3F2, that just simplified for Pi as upper bound.

Now as we have it for 1/linear one can get the inital problem (have not carried it out) using
partial fraction decomposition.

MMA answer

Yes, MMA 5 gives that 4F3 hypergeometric function for the definite integral, but for the indefinite integral the answer is also wrong. The function is a bit different, but it has a rather similar structure, also using dilog's. Its plot shows a bigger jump.

So, the difference is that the FTOC is not being used by MMA 5 for the definite integral. A lookup table is used instead? 

Apparently yes. Changing the upper limit to 9/10 it produces a wrong "dilog" answer that takes a much longer time and evaluates  numerically  to 0.384447-3.9169*I.

About the ugly bughery bbbllkk French & Saunders arcos integral!

HI

is my first time in high mathematics quarters of maples...

Has been a bit frustrating trying solving the Integral the old way, by paper and triks, substitutions and so... even more frustrating when I gave a try with matematica: not a second and here the solution (do know if is the right one, but it seams old fashon enough to be so): 

(1) input: [Integral]ArcTan (x)/(1+x^4) dx
 
(2)output: 1/2 ArcTan (ArcTan[x2])
 
(3)output: diff (integral output)->((ArcTan x)/(1+x4)) just to verify I were awake...
 
(4) imput: evaluate Int, x=1..4
 
(5) Output: 1/4 ArcTan ((-Sqr(2)*p+8 ArcTan[16]+Sqr(2)*(ArcTan[(4 *Sqr(2)/15]+ArcTanh[(4*Sqr(2)/17]))
 
What do you thinck, it is just allucination or ...
in any case how to know if a math prog gibes the right answers, in such unhandly cases?!
 
Thanks for the great insight which comes out from your discussion, I'm notv a mathematician though i have great passion for it ... as it happens quite often about the prittiest girl in the school...
 
Behave, if not
 
be good!
 
Federiclet(ITA)

 

ArcTan

The integrand was

arccos(x)/(1+x^4)

not

arctan(x)/(1+x^4)

And as you know,

diff(arctan(x),x);

                                                1
                                              ------
                                                   2
                                              1 + x

So, by the chain rule

arctan(arctan(x^2)):
diff(%,x);


           2 x
--------------------------
      4               2 2
(1 + x ) (1 + arctan(x ) )

which is a different function.

On the other hand, In Mathematica the input should be: 

Integrate[ArcTan[x]/(1 + x^4), x]

ie, with square brackets.

thanks for the reprimenda

In spite of the megabugaerror,

I am still alive

^_^

be good

f

Ah I forgot ... try substitute arccos(x) with 2x

then evaluate the resulting integral numerically from zero, or simplyfying simbolically, no polylog on sight ...and a rather simple and simmetrical solution

involving only arctanh and arccos. here the indefinite integral

  1|/2          1   (.25*arccos(x)^2+1)*|/2)
----- arctanh ---- -------------------------- +
   4            2  |/(.25arccos(x)^2 +1)

            1     (.25*arccos(x)^2-1)*|/2)
- arctanh(---- -------------------------
            2      |/(.25arccos(x)^2 +1)

 

F.

hope have been right ... ciao

Not clear for me

I am afraid that I do not understand whether "substitute arccos(x)
with 2x" means the change of variables (like that made by Jacques):

with(IntegrationTools):
J:=Int(arccos(x)/(1+x^4),x):
Jt:=(simplify@Change)(J,x=cos(2*t)) assuming 0<t,t<
Pi/4;

=-4*Int(t/(1+cos(2*t)^4)*sin(2*t),t);

Not sure either whether this is your result:

<br />
sqrt(2)/4*arctanh(1/2*((arccos(x)^2/4+1)*sqrt(2))/sqrt(arccos(x)^2/4+1))-arctanh(1/2*((arccos(x)^2/4-1)*sqrt(2))/sqrt(arccos(x)^2/4+1));<br />

But clearly it is different from value(Jt), which has sums
of dilogs. So, could you give the detail of your steps?

Robert Israel's picture

Surely not

That has a logarithmic singularity at x = cos(2), so it can't be an antiderivative of
arccos(x)/(1+x^4).

Axel Vogt's picture

well ...

Even if it was my intention to give a somwwhat detailed error report I put together
what was done above do give the result in Maple.

  Int( arccos(x)/(x - a), x = 0 .. 1 ) =
= Int(-t*sin(t)/(-cos(t)+a),t = 0 .. 1/2*Pi) =
= Int(ln(-cos(t)+a),t = 0 .. 1/2*Pi) - 1/2*Pi*ln(a) =
= Int(ln(-x+a)/(1-x^2)^(1/2),x = 0 .. 1) - 1/2*Pi*ln(a) = # let Maple evaluate it
= ln( (1+sqrt(1-1/(a^2)))/2 )*Pi/2 - 1/a*hypergeom([1/2, 1, 1],[3/2, 3/2],1/(a^2))

Let me call E the function given by the last expression.

Then it makes sense to use (complex) partial fraction for the original problem
using convert(1 / ( 1+x^4),fullparfrac) and this then writes as

  'Sum(-1/4*alpha*E(alpha),alpha = RootOf(1+Z^4))';
  allvalues(%): simplify(%,size); 

  evalf(%);

                     -----
                      \
                       )      (-alpha * E(alpha) / 4)
                      /
                     -----
              alpha = RootOf(1+Z^4)

  1/2 hypergeom([1/2, 1, 1], [3/2, 3/2], I) + 1/2 hypergeom([1/2, 1, 1], [3/2, 3/2], -I)

                         0.9225481756 + 0. I

which is the numerical value for  Int( arccos(x) / ( 1+x^4) , x=0 .. 1).


One can write the result as Re( hypergeom([1/2, 1, 1], [3/2, 3/2], I) ), but still
in terms of hypergeometrics 3F2, which I do not like too much - but have nothing
better.

May be one can do Int(ln(-x+a)/(1-x^2)^(1/2),x = 0 .. 1) through contour integrals,
but I am too long out of practicing that.

related answer

For this related integral:

J:=Int(arccos(x)/(1+x^4),x=-1..1):evalf(%);
2.723675968

The result is quite simple in terms of the roots of the unity:

       /          1 + alpha1              1 + alpha2 \
1/4 Pi |alpha1 ln(----------) + alpha2 ln(----------)|
       \          alpha1 - 1              alpha2 - 1 /

evalf(eval(%,[alpha1=(1+I)/sqrt(2),alpha2=(-1+I)/sqrt(2)]));

2.723675968+0.*I

No hypergeometric, Lerch, etc. Details tomorrow.

this is nice

In fact, the calculation of the integral over the interval (-1,1):

J:=Int(arccos(x)/(1+x^4),x=-1..1);

is quite simple using the symmetries of the integrand, ie its even denominator
invariant under the change x=-u and the transformation of arccos(x) under this
change:

with(IntegrationTools):
Change(J,x=-u);
Expand(%):
subsop(1=value(op(1,%)),%);
combine(%,ln);

<br />
Int((Pi-arccos(u))/(1+u^4),u = -1 .. 1);<br />

<br />
1/4*Pi*2^(1/2)*(-ln((2-2^(1/2))/(2+2^(1/2)))+Pi)-Int(1/(1+u^4)*arccos(u),u =-1 .. 1);<br />

As the second term is -J, it turns out that the first term is 2*J. Ie the
value of J is:

op(1,%)/2;
evalf(%);

2.723675968

Geometrically, the curve of arccos(x) divides the rectangle of height Pi and
base on the interval (-1,1) in two halves. So, because of the even
denominator, J the integral below the curve is equal to the integral above the
curve up to Pi.

This does not solve the original integral but it is nice and value(J) also
produces a wrong and horrible sum of dilogs:

evalf(value(J));

-.7657561321-.4274644056*I

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}