Re: Integrals of Fourier Series

• Subject: [mg3243] Re: Integrals of Fourier Series
• From: BobHanlon at aol.com
• Date: 20 Feb 1996 06:50:42 -0600
• Approved: usenet@wri.com
• Distribution: local
• Newsgroups: wri.mathgroup
• Organization: Wolfram Research, Inc.
• Sender: daemon at wri.com

```"Mma doesn't know that Sum and Integrate commute, and that Sin[n Pi] = 0 for
all integer n.

How to do this?"
____________________

Unprotect[Sin, Cos]; Clear[Sin, Cos];
Sin[n_ Pi /; IntegerQ[n]] = 0;
Cos[n_ Pi /; IntegerQ[n]] := (-1)^n;
Protect[Sin, Cos];

Examples:

n/: IntegerQ[n] = True;
Print[StringForm["`` = ``\n", #, ToExpression[#] //
Simplify]]& /@ {"Sin[n Pi]", "Sin[(2n+1) Pi/2]",
"Cos[n Pi]", "Cos[(2n+1) Pi/2]"};

Sin[n Pi] = 0

n
Sin[(2n+1) Pi/2] = (-1)

n
Cos[n Pi] = (-1)

Cos[(2n+1) Pi/2] = 0

(* sumSquared converts square of sum to nested sums *)
sumSquared = {Sum[term_, {n_, lower_, upper_}]^2 :>
Sum[term (term /. n :> m), {n, lower, upper},
{m, lower, upper}]};

Example of using sumSquared:

Print[StringForm["`` = ``",
temp = Sum[A[n] x^n/n!, {n, 1, Infinity}]^2,
temp /. sumSquared]]

n
x  A[n]                   2
Sum[-------, {n, 1, Infinity}]  =
n!

m + n
x      A[m] A[n]
Sum[----------------, {n, 1, Infinity},
m! n!

{m, 1, Infinity}]

(* commuteIntegrateSum converts integral of sum to
sum of integrals -- single or double sums *)
commuteIntegrateSum = {
Integrate[Sum[term_, {n_, lower_, upper_}], x_] :>
Sum[Integrate[term, x], {n, lower, upper}],
Integrate[Sum[term_, {n1_, lower1_, upper1_},
{n2_, lower2_, upper2_}], x_] :>
Sum[Integrate[term, x], {n1, lower1, upper1},
{n2, lower2, upper2}] };

Example of using commuteIntegrateSum:

Print[StringForm["`` = ``",
temp = Integrate[Sum[A[n] x^n/n!, {n, 1, Infinity}], x],
temp /. commuteIntegrateSum /. n! -> (n+1)!/(n+1)]]

n
x  A[n]
Integrate[Sum[-------, {n, 1, Infinity}], x] =
n!

1 + n
x      A[n]
Sum[-----------, {n, 1, Infinity}]
(1 + n)!

Example of using both sumSquared and commuteIntegrateSum:

Print[StringForm["`` = ``",
temp = Integrate[Sum[A[n] x^n/n!, {n, 1, Infinity}]^2, x],
temp /. sumSquared /. commuteIntegrateSum]]

n
x  A[n]                   2
Integrate[Sum[-------, {n, 1, Infinity}] , x] =
n!

1 + m + n
x          A[m] A[n]
Sum[--------------------, {n, 1, Infinity},
(1 + m + n) m! n!

{m, 1, Infinity}]

```

• Prev by Date: Re: Integrals of Fourier Series
• Next by Date: mathHDF on a PowerPC?
• Previous by thread: Re: Integrals of Fourier Series
• Next by thread: Re: Integrals of Fourier Series