Rectangular impulse built
public static double calcimpuls(double U,double T,double x) { if (x >= 0 && x <= T) return U; else return 0; } After that, the direct Fourier transform begins.
In the formula, I call the result of the constructed rectangular pulse into the formula of the direct Fourier transform (Given the complexity of integration, the Euler formula is applied). Thus, I get the spectral density
public static Complex GetSpectralDensity(double U, double frequency, double T,double x) { NumericalIntegration integration = new NumericalIntegration(); double f = 1 / T; double w = 2 * Math.PI * f; return calcimpuls(U, T, x) * integration.Calculate(t => Math.Cos(w * t), 0, T) - Complex.ImaginaryOne * calcimpuls(U, T, x) * integration.Calculate(t=>Math.Sin(w*t),0,T); } From the theory, the spectral density of amplitudes is a module of the complex spectral density, therefore
Given that the graph below is very similar to the graph y = sin * x / x, but without negative coordinates, then I execute the following code (module so that there are no negative numbers)
public static double GetSinModul(double U, double frequency, double T) { double x7 = GetSpectralDensity(U, frequency, T, 1);------ Неявное преобразование типа "System.Numerics.Complex" в "double" невозможно return U *T * Math.Abs(Math.Sin(x7) / x7); } The result should be such a schedule.
The problem is in converting System.Numerics.Complex and double.
I decided that it would be better to assign the result of the execution of the GetSpectralDensity method to the variable x7, for further calculation. But the problem in the conversion remained. The implicit conversion of the type "System.Numerics.Complex" to "double" is impossible
The formula with an imaginary unit and therefore the method will be Complex and not double. And the compiler will not allow it.



GetSpectralDensityreturnsComplex. The compiler does not know how to get adoublefrom it. TakeX, dropY? TakeY, dropX? TakeR? How do you want? The compiler does not convert for you. - VladDGetSpectralDensity(U, frequency, T, 1).Magnitude- kmv