[...]
>
>
> It gets much, much worse for n = 14 and n = 18. Also, I suspect that
> roundoff errors could be a serious issue when proceeding from the
> symbolic answer. So, definitely use evalf(Int...)) instead of the
> other form.
>
> RGV
Hello there,
thank you for the hint, I just tried "Int" instead of "int" and it gives
the right answers:
> evalf(Int(cos(t)/(1+t^10), t=-infinity..infinity));
1.670102865
> evalf(Int(cos(t)/(1+t^14), t=-infinity..infinity));
1.677119575
> evalf(Int(cos(t)/(1+t^18), t=-infinity..infinity));
1.679603273
> evalf(Int(cos(t)/(1+t^22), t=-infinity..infinity));
1.680769183
So the error with "int" lies not with the numerics but with the symbolic
integrator. As I pointed out above where I give a closed formula these
integrals have simple explicit representations, namely
> print(I1);
exp(t I)
k -> 2 I Pi add(residue(----------, t = v(q, k)), q = 0 .. k - 1)
(2 k)
1 + t
> print(v);
1/2 I Pi Pi q I
(q, k) -> exp(-------- + ------)
k k
> I1(5);
/
| (3/5) (1/10) (4/5) (3/10)
2 I Pi |-1/10 exp((-1) ) (-1) - 1/10 exp((-1) ) (-1)
|
\
7/10 9/10 \
(-1) (-1) |
- 1/10 I exp(-1) - 1/10 -------------- - 1/10 --------------|
(1/5) (2/5) |
exp((-1) ) exp((-1) )/
> I1(7);
/
|
|
| (4/7) (1/14) (5/7) (3/14)
2 I Pi |-1/14 exp((-1) ) (-1) - 1/14 exp((-1) ) (-1)
|
\
9/14
(6/7) (5/14) (-1)
- 1/14 exp((-1) ) (-1) - 1/14 I exp(-1) - 1/14 --------------
(1/7)
exp((-1) )
11 13 \
-- -- |
14 14 |
(-1) (-1) |
- 1/14 -------------- - 1/14 --------------|
(2/7) (3/7) |
exp((-1) ) exp((-1) )/
> I1(9);
/
|
| 1/2
| (5/9) (1/18) 2 exp(1/2 I 3 ) exp(-1/2)
2 I Pi |-1/18 exp((-1) ) (-1) + ---------------------------
| 1/2
\ 18 I - 18 3
(7/9) (5/18) (8/9) (7/18)
- 1/18 exp((-1) ) (-1) - 1/18 exp((-1) ) (-1)
11 13
-- --
18 18
(-1) (-1)
- 1/18 I exp(-1) - 1/18 -------------- - 1/18 --------------
(1/9) (2/9)
exp((-1) ) exp((-1) )
17 \
-- |
1/2 18 |
2 exp(-1/2 I 3 ) exp(-1/2) (-1) |
- ---------------------------- - 1/18 --------------|
1/2 (4/9) |
-18 I - 18 3 exp((-1) )/
I can confirm that the symbolic integrator produces truly massive
results for these integrals. I guess the question to ask here is why
does the integrator not evaluate these integrals through residues, which
gives compact answers that are orders of magnitude smaller and
mathematically correct.
With the above formulas care must be taken to use the same branch of the
logarithm for all exponentials. In the expressions above MAPLE has
turned exp(i pi) from the original formula (see my first message) back
into -1, which, when exponentiated, is multivalued. That's why the
powers of -1 should be computed with a branch of the logarithm that has
log(-1) = i pi.
Here are some truly scary statistics:
> length(convert(int(cos(t)/(1+t^10), t=-infinity..infinity),string));
8806
> length(convert(int(cos(t)/(1+t^14), t=-infinity..infinity),string));
22476
> length(convert(int(cos(t)/(1+t^18), t=-infinity..infinity),string));
42751
> length(convert(int(cos(t)/(1+t^22), t=-infinity..infinity),string));
84282
The output of the integrator shows exponential growth! (Compare to my
formula, where the number of terms is linear.)
Best regards,
Marko Riedel