Created a list into which I will upload my values.
List<double> moduls = new List<double>(); I load my values from the method
for (int frequency = frc, counter = 1; frequency <= frc1; frequency++, counter++) { moduls.Add(GetSpectralDensityOfAmplitude(GetSpectralDensity(U, frequency, T))); } And now the most interesting thing is how to multiply each element of the list by cosine
public static Complex reverstrans(double U, double anguarFrequency, double T,int frc,int frc1,double shag)///Обратное преобразование Фурье { NumericalIntegration integration = new NumericalIntegration(); int t = 1; List<double> moduls = new List<double>(); for (int frequency = frc, counter = 1; frequency <= frc1; frequency++, counter++) { moduls.Add(GetSpectralDensityOfAmplitude(GetSpectralDensity(U, frequency, T))); } return (1 / 2 * Math.PI) * integration.Calculate(w => moduls.ForEach(x1 => x1 * Math.Cos(anguarFrequency * t)),0, T); ----Проблемная строка } The question is
How to multiply and add each element of the list through ForEach? The problem is that swears
Ошибка 1 В качестве оператора могут использоваться только выражения присваивания, вызова, инкремента, декремента и ожидания Here is the Calculate method.
class TrapezoidalRule : NumericalIntegrationRule { public double Calculate(Func<double,double> func, double min, double max, double subintervalsCount) { double result = 0; double step = (max - min) / subintervalsCount; for (double i = min; i < max; i += step) result += ((func(i) + func(i + step)) / 2) * step; return result; } } It will not be possible to bring the ForEach integration limits inside, since then you will have to redo the Calculate method and it is tied to many things.
And if I work without creating a List <>, then I have only zeros. Through List <> I can see my values and navigate when debugging
How can this problem be solved?
And why do I need it
This is what I need to get results that will allow me to derive approximately such a schedule.

ForEachreturns nothing, this time, apparently, the number of required parameters in Calculate and transmitted is different: 4 is required (func, min, max, subintervalsCount), 3 is transmitted (w => moduls.ForEach (x1 => x1 * Math.Cos (anguarFrequency * t)), 0, T), that is, there are two more errors from the question - Grundyawaitor the creation of a new object - Grundy