(*^

::[paletteColors = 128; 
	fontset = title, "New York", 24, L3, center, bold, nohscroll;
	fontset = subtitle, "New York", 18, L2, center, bold, nohscroll;
	fontset = subsubtitle, "New York", 14, L2, center, bold, nohscroll;
	fontset = section, "New York", 14, L2, bold, nohscroll, grayBox;
	fontset = subsection, "New York", 12, L2, bold, nohscroll, blackBox;
	fontset = subsubsection, "New York", 10, L2, bold, nohscroll, whiteBox;
	fontset = text, "New York", 12, L2, nohscroll;
	fontset = smalltext, "New York", 10, L2, nohscroll;
	fontset = input, "Courier", 12, L2, bold, nowordwrap;
	fontset = output, "Courier", 12, L2, nowordwrap;
	fontset = message, "Courier", 12, L2, R65535, nowordwrap;
	fontset = print, "Courier", 12, L2, nowordwrap;
	fontset = info, "Courier", 12, L2, nowordwrap;
	fontset = postscript, "Courier", 12, L2, nowordwrap;
	fontset = name, "Geneva", 10, L2, italic, B65535, nowordwrap, nohscroll;
	fontset = header, "Times", 10, L2;
	fontset = footer, "Times", 12, L2, center;
	fontset = help, "Geneva", 10, L2, nohscroll;
	fontset = clipboard, "New York", 12, L2;
	fontset = completions, "New York", 12, L2, nowordwrap;
	fontset = network, "Courier", 10, L2, nowordwrap;
	fontset = graphlabel, "Courier", 12, L2, nowordwrap;
	fontset = special1, "New York", 12, L2, nowordwrap;
	fontset = special2, "New York", 12, L2, center, nowordwrap;
	fontset = special3, "New York", 12, L2, right, nowordwrap;
	fontset = special4, "New York", 12, L2, nowordwrap;
	fontset = special5, "New York", 12, L2, nowordwrap;]
:[font = input; ]
(* This file demonstrates the combined use of the packages
   Declare.m, DeltaTheta.m, Trig.m, (P.J)
   and DefiniteIntegate.m (standard package) *)
(* Modify the << -commands before starting if necessary.*)
(* If you have a MacII and a remote kernel on a Unix-machine,
   then you can simply use EvaluateNotebook from Action menu.*)
(* Note: it is recommended that you load DefiniteIntegrate.m
   BEFORE loading DeltaTheta.m; otherwise some integrals
   can give meaningless results (which are easily recognized
   to be meaningless, though) *)
:[font = input; startGroup; ]
<<Misc/Declare.m
:[font = print; inactive; endGroup; ]
{Declare, NonPositive, RealQ, NonZero, EqnCanonical}
:[font = input; ]
Declare[{n,m},Integer]; Declare[{x,y},Real];
:[font = input; startGroup; ]
NonNegative[x^2 + y^2]
:[font = output; inactive; output; endGroup; ]
True
;[o]
True
:[font = input; startGroup; ]
Negative[x^2+y^2]
:[font = output; inactive; output; endGroup; ]
False
;[o]
False
:[font = input; startGroup; ]
EvenQ[(2n)(m-4)]
:[font = output; inactive; output; endGroup; ]
True
;[o]
True
:[font = input; startGroup; ]
EvenQ[n m]
:[font = output; inactive; output; endGroup; ]
EvenQ[m*n]
;[o]
EvenQ[m n]
:[font = input; startGroup; ]
OddQ[(2n-1)2m]
:[font = output; inactive; output; endGroup; ]
False
;[o]
False
:[font = input; startGroup; ]
OddQ[Expand[(2n-1)2m]]
:[font = output; inactive; output; endGroup; ]
False
;[o]
False
:[font = input; startGroup; ]
OddQ[2n + 4 m]
:[font = output; inactive; output; endGroup; ]
False
;[o]
False
:[font = input; startGroup; ]
Positive[2 n]
:[font = output; inactive; output; endGroup; ]
True == Positive[n]
;[o]
True == Positive[n]
:[font = input; startGroup; ]
Negative[n]
:[font = output; inactive; output; endGroup; ]
!NonNegative[n]
;[o]
!NonNegative[n]
:[font = input; startGroup; ]
IntegerQ[n]
:[font = output; inactive; output; endGroup; ]
True
;[o]
True
:[font = input; startGroup; ]
Positive[Exp[-x^2]]
:[font = output; inactive; output; endGroup; ]
True
;[o]
True
:[font = input; startGroup; ]
NonNegative[Exp[-x^2]]
:[font = output; inactive; output; endGroup; ]
True
;[o]
True
:[font = input; ]
<<Misc/Trig.m
:[font = input; ]
<<Calculus/DefiniteIntegrate.m
:[font = input; ]
<<DeltaTheta/DeltaTheta.m
:[font = input; startGroup; ]
?FourierCoefficient
:[font = info; inactive; endGroup; ]
FourierCoefficient[f,n,x,a,b] gives the nth   Fourier coefficient of f
   when f is expanded to complex Fourier series   in the interval [a,b].
   a and b are optional, defaults are 0 and 2 Pi.
:[font = input; startGroup; ]
FourierCoefficient[HeavisideTheta[x],n,x,-1,1]
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
(-I/(Pi*n) + (I*E^(-I*Pi*n))/(Pi*n))/2
;[o]
          -I Pi n
 -I    I E
---- + ----------
Pi n      Pi n
-----------------
        2
:[font = input; startGroup; ]
TrigCanonical[%]
:[font = output; inactive; output; endGroup; ]
(-I/(Pi*n) + (I*E^(-I*Pi*n))/(Pi*n))/2
;[o]
          -I Pi n
 -I    I E
---- + ----------
Pi n      Pi n
-----------------
        2
:[font = input; startGroup; ]
ComplexToTrig[%]
:[font = output; inactive; output; endGroup; ]
(I + -I*(-1)^n)/(2*(-1)^n*Pi*n)
;[o]
           n
I + -I (-1)
------------
      n
2 (-1)  Pi n
:[font = input; startGroup; ]
%/.n->2m
:[font = output; inactive; output; endGroup; ]
0
;[o]
0
:[font = input; startGroup; ]
%%/.n->2m+1
:[font = output; inactive; output; endGroup; ]
-I/(Pi*(1 + 2*m))
;[o]
     -I
------------
Pi (1 + 2 m)
:[font = input; startGroup; ]
FourierCoefficient[x^2 HeavisideTheta[x],n,x,-1,1]
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
(E^(-I*Pi*n)*((-2*I)/(Pi^3*n^3) + 2/(Pi^2*n^2) + I/(Pi*n)) + 
    (2*I)/(Pi^3*n^3))/2
;[o]
 -I Pi n   -2 I      2       I       2 I
E        (------ + ------ + ----) + ------
            3  3     2  2   Pi n      3  3
          Pi  n    Pi  n            Pi  n
------------------------------------------
                    2
:[font = input; startGroup; ]
ComplexToTrig[%]
:[font = output; inactive; output; endGroup; ]
(-2*I + 2*I*(-1)^n + 2*Pi*n + I*Pi^2*n^2)/(2*(-1)^n*Pi^3*n^3)
;[o]
               n                2  2
-2 I + 2 I (-1)  + 2 Pi n + I Pi  n
------------------------------------
                 n   3  3
           2 (-1)  Pi  n
:[font = input; startGroup; ]
%/.n->2m //Simplify
:[font = output; inactive; output; endGroup; ]
(1 + I*Pi*m)/(4*Pi^2*m^2)
;[o]
1 + I Pi m
----------
     2  2
 4 Pi  m
:[font = input; startGroup; ]
%%/.n->2m+1 //Simplify
:[font = output; inactive; output; endGroup; ]
-(-4*I + 2*Pi*(1 + 2*m) + I*Pi^2*(1 + 2*m)^2)/(2*Pi^3*(1 + 2*m)^3)
;[o]
                              2          2
-(-4 I + 2 Pi (1 + 2 m) + I Pi  (1 + 2 m) )
-------------------------------------------
                 3          3
             2 Pi  (1 + 2 m)
:[font = input; startGroup; ]
FourierCoefficient[x,n,x]
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
(E^(-2*I*Pi*n)*(n^(-2) + (2*I*Pi)/n) - n^(-2))/(2*Pi)
;[o]
 -2 I Pi n   -2   2 I Pi     -2
E          (n   + ------) - n
                    n
-------------------------------
             2 Pi
:[font = input; startGroup; ]
Integrate[f[x],{x,0,2Pi}]
:[font = output; inactive; output; endGroup; ]
Integrate[f[x], {x, 0, 2*Pi}]
;[o]
Integrate[f[x], {x, 0, 2 Pi}]
:[font = input; startGroup; ]
FourierCoefficient[f[x],n,x]
:[font = output; inactive; output; endGroup; ]
Integrate[E^(-I*n*x)*f[x], {x, 0, 2*Pi}]/(2*Pi)
;[o]
           -I n x
Integrate[E       f[x], {x, 0, 2 Pi}]
-------------------------------------
                2 Pi
:[font = input; startGroup; ]
FourierCoefficient[Exp[-x^2],n,x,-1,1]
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
(-(Pi^(1/2)*Erf[-1 + I/2*Pi*n])/(2*E^((Pi^2*n^2)/4)) + 
    (Pi^(1/2)*Erf[1 + I/2*Pi*n])/(2*E^((Pi^2*n^2)/4)))/2
;[o]
                    I                           I
-(Sqrt[Pi] Erf[-1 + - Pi n])   Sqrt[Pi] Erf[1 + - Pi n]
                    2                           2
---------------------------- + ------------------------
             2  2                         2  2
          (Pi  n )/4                   (Pi  n )/4
       2 E                          2 E
-------------------------------------------------------
                           2
:[font = input; startGroup; ]
ComplexToTrig[%]//Simplify
:[font = output; inactive; output; endGroup; ]
(-(Pi^(1/2)*Erf[-1 + I/2*Pi*n]) + Pi^(1/2)*Erf[1 + I/2*Pi*n])/
  (4*E^((Pi^2*n^2)/4))
;[o]
                    I                           I
-(Sqrt[Pi] Erf[-1 + - Pi n]) + Sqrt[Pi] Erf[1 + - Pi n]
                    2                           2
-------------------------------------------------------
                           2  2
                        (Pi  n )/4
                     4 E
:[font = input; startGroup; ]
%/.n->2m
:[font = output; inactive; output; endGroup; ]
(-(Pi^(1/2)*Erf[-1 + I*Pi*m]) + Pi^(1/2)*Erf[1 + I*Pi*m])/
  (4*E^(Pi^2*m^2))
;[o]
-(Sqrt[Pi] Erf[-1 + I Pi m]) + Sqrt[Pi] Erf[1 + I Pi m]
-------------------------------------------------------
                            2  2
                          Pi  m
                       4 E
:[font = input; startGroup; ]
%%/.n->2m+1
:[font = output; inactive; output; endGroup; ]
(-(Pi^(1/2)*Erf[-1 + I/2*Pi*(1 + 2*m)]) + 
    Pi^(1/2)*Erf[1 + I/2*Pi*(1 + 2*m)])/(4*E^((Pi^2*(1 + 2*m)^2)/4))
;[o]
                     I
(-(Sqrt[Pi] Erf[-1 + - Pi (1 + 2 m)]) + 
                     2
 
                                               2          2
                     I                      (Pi  (1 + 2 m) )/4
    Sqrt[Pi] Erf[1 + - Pi (1 + 2 m)]) / (4 E                  )
                     2
:[font = input; startGroup; ]
FourierCoefficient[Sinh[x],n,x]
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
(1/(2*(-1 + -I*n)) - E^(-2*Pi + -2*I*Pi*n)/(2*(-1 + -I*n)) - 
    1/(2*(1 + -I*n)) + E^(2*Pi + -2*I*Pi*n)/(2*(1 + -I*n)))/(2*Pi)
;[o]
                 -2 Pi + -2 I Pi n                   2 Pi + -2 I Pi n
      1         E                         1         E
------------- - ------------------ - ------------ + -----------------
2 (-1 + -I n)     2 (-1 + -I n)      2 (1 + -I n)     2 (1 + -I n)
---------------------------------------------------------------------
                                2 Pi
:[font = input; startGroup; ]
ComplexToTrig[%]//Simplify
:[font = output; inactive; output; endGroup; ]
(E^(-2*Pi + -2*I*Pi*n)*(-1 - E^(4*Pi) + 2*E^(2*Pi + 2*I*Pi*n) + I*n + 
      -I*E^(4*Pi)*n))/(4*Pi*(-1 + I*n)*(1 + I*n))
;[o]
  -2 Pi + -2 I Pi n        4 Pi      2 Pi + 2 I Pi n
(E                  (-1 - E     + 2 E                + I n + 
 
          4 Pi
      -I E     n)) / (4 Pi (-1 + I n) (1 + I n))
:[font = input; startGroup; ]
%/.n->2m //Simplify
:[font = output; inactive; output; endGroup; ]
(E^(-2*Pi + -4*I*Pi*m)*(-1 - E^(4*Pi) + 2*E^(2*Pi + 4*I*Pi*m) + 2*I*m + 
      -2*I*E^(4*Pi)*m))/(4*Pi*(-1 + 2*I*m)*(1 + 2*I*m))
;[o]
  -2 Pi + -4 I Pi m        4 Pi      2 Pi + 4 I Pi m
(E                  (-1 - E     + 2 E                + 2 I m + 
 
            4 Pi
      -2 I E     m)) / (4 Pi (-1 + 2 I m) (1 + 2 I m))
:[font = input; startGroup; ]
%%/.n->2m+1 //Simplify
:[font = output; inactive; output; endGroup; ]
(E^((-2 - 2*I)*Pi + -4*I*Pi*m)*
    (-1 - E^(4*Pi) + 2*E^((2 + 2*I)*Pi + 4*I*Pi*m) + I*(1 + 2*m) + 
      -I*E^(4*Pi)*(1 + 2*m)))/(4*Pi*(-1 + I + 2*I*m)*(1 + I + 2*I*m))
;[o]
  (-2 - 2 I) Pi + -4 I Pi m        4 Pi      (2 + 2 I) Pi + 4 I Pi m
(E                          (-1 - E     + 2 E                        + 
 
                        4 Pi
      I (1 + 2 m) + -I E     (1 + 2 m))) / 
 
  (4 Pi (-1 + I + 2 I m) (1 + I + 2 I m))
:[font = input; startGroup; ]
(* This is not correct for n=0: *)
FourierCoefficient[1,n,x]//ComplexToTrig//Simplify
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = output; inactive; output; endGroup; ]
0
;[o]
0
:[font = input; startGroup; ]
(* But the following IS correct: *)
Table[ FourierCoefficient[1,n,x],{n,-10,10}]//
  ComplexToTrig//Simplify
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = message; inactive; ]
Integrate::endpts: 
   Warning: definite integral being evaluated using values of the
    indefinite integral at endpoints; singularities may be missed.
:[font = message; inactive; ]
General::stop: 
   Further output of Integrate::endpts
     will be suppressed during this calculation.
:[font = output; inactive; output; endGroup; ]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
;[o]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
^*)