There is a formula

enter image description here

The first is the Fourier transform itself, and the second lower is the formula for finding the spectral density (a formula based on the first), what I am trying to program and solve.

Separately added class of complex numbers in order not to clutter up the main form.

Such a question, which method can I solve the integral in the 2nd formula?

All searches were cited with references to alglib, but they are forbidden to use (anti-plagiarism and the department’s prohibition on the use of ready-made resources and libraries)

The code snippet written below is my attempt to recreate the solution of the problem step by step and formula. But there is one question, how to describe in its program the integral of the 2nd formula and then write it into its function.

public double calculate1(double u) { int nmax = 512; int k=0,t=1; double [] Rex=new double[nmax/2+1]; double [] Imx= new double[nmax/2+1]; double[] x = new double[nmax]; double f, w,ur=0,uit=0 ; Complex ct; int U = Convert.ToInt32(textBox1.Text); int T = Convert.ToInt32(textBox2.Text); Rex[k]=0; Imx[k]=0; for (double j = 0; j <= nmax / 2; j++) { f = 1 / T; w = 2 * Math.PI * f; u=U * Math.Exp( -j * w * t); } uit = U * T;//расчёт значения спектральной плотности амплитуд на нулевой частоте return u; } 
  • one
    uh ... numerical integration is not an option? if memory does not change, a certain integral is numerically equal to the area of ​​a curvilinear trapezium, the “curve” side of which is given by the integrand. And how to calculate the area of ​​such a trapezium is written in any textbook in at least three ways - rdorn

1 answer 1

I will not evaluate the accuracy of the above formulas (and their applicability to the problem being solved). Suppose all the rules here. And then - any definite integral can be calculated by numerical integration. Those. the interval [0 ... tau] is divided into many segments (the more, the more accurate the result). Later in the cycle, you calculate the value of the integrand at t (for example, the first point of each segment), multiply by the length of the segment, i.e. you get the area of ​​the corresponding rectangle, and you accumulate these values. At the end of the cycle, this amount will be the result. Well, for performance, all values ​​that do not depend on a loop variable, i.e. from t - calculate outside the loop, once (for example, in the example given by the questioner, this is f and w)