I code like follower:

```
public partial class FormTest : Form
{
public FormTest()
{
this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
InitializeComponent();
}
public static double[] GetHarmonic(double[] dChannel, int nOrder, ref double dMagnitude, ref double dInitialPhase)
{
int nSamplePoints = dChannel.Length;
Complex32[] HarmonicComplexArr = new Complex32[nSamplePoints];
for (int i = 0; i < nSamplePoints; i++)
{
HarmonicComplexArr[i] = new Complex32((float)dChannel[i], 0);
}
Fourier.Forward(HarmonicComplexArr, FourierOptions.Matlab);//FFT
//frequency spectrum data
//double[] ArrFreq = new double[nSamplePoints];
for (int i = 0; i < nSamplePoints; i++)
{
//ArrFreq[i] = HarmonicComplexArr[i].Magnitude;
if (i == nOrder)//i==0 DC component i==1 First Harmonic,i==2 Second Harmonic
{
HarmonicComplexArr[i] *= 2;
dMagnitude = HarmonicComplexArr[i].Magnitude;
dInitialPhase = HarmonicComplexArr[i].Phase;
}
else
{
HarmonicComplexArr[i] = new Complex32(0, 0);
}
}
Fourier.Inverse(HarmonicComplexArr, FourierOptions.Matlab);//逆傅里叶变换
double[] dHarmonic = new double[nSamplePoints];
for (int i = 0; i < nSamplePoints; i++)
{
dHarmonic[i] = HarmonicComplexArr[i].Real;
}
return dHarmonic;
}
private void FormTest_Load(object sender, EventArgs e)
{
int nSamplePointsPerCycle = 720;
double[] dChannel = new double[nSamplePointsPerCycle];
for (int i = 0; i < nSamplePointsPerCycle; i++)
{
dChannel[i] = 5 * Math.Cos(2 * Math.PI * i / nSamplePointsPerCycle + 0) + 2 * Math.Cos(4 * Math.PI * i / nSamplePointsPerCycle + 0);
}
double dMagnitude = 0;
double dInitialPhase = 0;
double[] dFirstHarmonic = GetHarmonic(dChannel, 1, ref dMagnitude, ref dInitialPhase);
lblFirstMagnitude.Text = dMagnitude.ToString();
double[] dSecondHarmonic = GetHarmonic(dChannel, 2, ref dMagnitude, ref dInitialPhase);
lblSecondMagnitude.Text = dMagnitude.ToString();
chtChannel.Series["OriginalSeries"].Points.Clear();
chtChannel.Series["FirstHarmonicSeries"].Points.Clear();
chtChannel.Series["SecondHarmonicSeries"].Points.Clear();
for (int i = 0; i < nSamplePointsPerCycle; i++)
{
chtChannel.Series["OriginalSeries"].Points.AddXY(360 * i / nSamplePointsPerCycle, dChannel[i]);
chtChannel.Series["FirstHarmonicSeries"].Points.AddXY(360 * i / nSamplePointsPerCycle, dFirstHarmonic[i]);
chtChannel.Series["SecondHarmonicSeries"].Points.AddXY(360 * i / nSamplePointsPerCycle, dSecondHarmonic[i]);
}
}
}
```

The result of the code show in the fig.1.

- The Yellow curve is the first harmonic.The red curve is second harmonic.They are all right because I I multiply the complex by two. Such as “HarmonicComplexArr[i] *= 2;” So the first question is why I need to multiply the complex by two?
- You can focus on the two lables at the top of the window，which named ‘First Harmoic Magnitude’ and ‘Second Harmonic Magnitude’. And they are be computed by the code “dMagnitude = HarmonicComplexArr[i].Magnitude;”. I don’t know what dMagnitude mean. And I try to change nSamplePointsPerCycle, the dMagnitude will be changed also. I found 2 * dMagnitude/nSamplePointsPerCycle always equal to Harmoic Curve’s Magnitude. So the second question is What the story about this.

Thanks all for your attention.

Fig.1