Finding Complex Coefficients of Complex Form Fourier Series

Rifat Aras, Duc T. Nguyen
Old Dominion University
United States of America
dnguyen@odu.edu
Website: http://numericalmethods.eng.usf.edu
Version: Mathematica 8; Last Revised: October, 24, 2011

Initialization

Clearing the definitions of all symbols in the current context:

ClearAll[Evaluate[Context[]<>"*"]];
dataPointsR={};
dataPointsI={};
nDataPoints=0;
realCoefList={};
imagCoefList={};

Introduction

The following worksheet demonstrates how to compute unknown complex Fourier coefficients of a Discrete Fourier Series. The user inputs the complex data points to the text fields provided followed by clicking “Record Data Point”. When all the data is input, “Calculate Coefficients” button is clicked.

Section 1: Function Definitions

Find the complex coefficients Cn. Input parameters are: number of data points entered by the user, list of the real parts of the input data points, and list of the imaginary parts of the input data points.

findCoefficients[numDataPoints_, realDataPoints_, imagDataPoints_]:=(
Do[
thetaList=Table[k*(2*Pi/numDataPoints)*n,{k,0,numDataPoints-1}];
cnR=realDataPoints.Cos[thetaList]+imagDataPoints.Sin[thetaList];
cnI=imagDataPoints.Cos[thetaList]-realDataPoints.Sin[thetaList];
AppendTo[realCoefList,cnR];
AppendTo[imagCoefList,cnI];
Print["C_"<>ToString[n]<>": "<>ToString[N[cnR]]<>" + "<>ToString[N[cnI]]<>" i"];
,{n,0,numDataPoints-1}];
);

Section 2: Graphical User Interface Definition

Definition of the graphical user interface.

userInterface = Panel[
Dynamic[
Column[
{
"Imaginary Fourier Coefficients",
Row[{"Enter data point: ",InputField[Dynamic[realPart],FieldSize->Tiny]," + ",InputField[Dynamic[imagPart],FieldSize->Tiny]," i"}],
Row[{Button["Record Data Point",{AppendTo[dataPointsR,realPart],AppendTo[dataPointsI,imagPart],nDataPoints++}],"Number of data points: ",nDataPoints}],
Row[{Button["Calculate Coefficients",findCoefficients[nDataPoints, dataPointsR, dataPointsI]]}]
}
]
]
];

Section 3: Dynamic Module for Coefficient Computation

Dynamic[userInterface]

N[cnR]

N[cnI]

Legal Notice: The copyright for this application is owned by the author(s). Neither Wolfram Research nor the author(s) are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.