This question was the result. Unable to convert lambda expressions to delegate type.
Inverse Fourier transform, the transformation between Complex and double
Get rid of implicit conversion
I will write separately the code and explanation (In the program they go sequentially) It turned out that I do not need to find U '(w) -U' '(w) since this is an algebraic record of a complex number.
So I found separately U '(w) and U' '(w), and then just put them together
At the forum, mathematicians said the presence of the frequency response and phase response in the formula for the inverse transformation is required, so I solve them separately
Immediately I will write that the limits of integration in my frc,frc1 are my frequency boundaries for plotting graphs, since judging by the theory, if I integrate the forward in time of the signal (from 0 to TAU), then back in frequency.
Problem in the return line
Неявное преобразование типа "System.Numerics.Complex" в "double" невозможно BUT IN THE COURSE OF EXPERIMENTS, IT WAS NOTED THAT
I just have to write public Complex reverstrans() then the problem of implicit conversion is solved without problems
As I was indicated here earlier, for plotting graphs, it is NECESSARY to DRAW the real part from a complex number and construct a graph on it
This is what was indicated. Moreover, the function U (w) is even (always) - and therefore the imaginary part of u (t) will go to zero (mathematically), only the real will remain. This is what you need to draw. (C) Pavel Mayorov
Also presented are my humble attempt to remove a real number from a complex number
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Numerics; namespace MainFormProg1 { public partial class FurierTransformReverse : Form { public FurierTransformReverse() { InitializeComponent(); } public double U=10;//Амплитуда public double T=1;//Период double shag=0.01;//Шаг public int frc=-100;//Начало диапазона частоты построения графика public int frc1=100;//Конец диапазон частоты построения графика введите сюда код interface NumericalIntegrationRule { double Calculate(Func<double, double> func, double min, double max, double subintervalsCount); } class NumericalIntegration { public readonly NumericalIntegrationRule DefaultRule = null; public readonly int DefaultSubintervalsCount = 100;//100000 public NumericalIntegration() { DefaultRule = new TrapezoidalRule(); } public NumericalIntegration(NumericalIntegrationRule defaultRule) { DefaultRule = defaultRule; } public NumericalIntegration(NumericalIntegrationRule defaultRule, int defaultSubintervalsCount) : this(defaultRule) { DefaultSubintervalsCount = defaultSubintervalsCount; } public double Calculate(NumericalIntegrationRule rule, Func<double, double> func, double min, double max, double subintervalsCount) { return rule.Calculate(func, min, max, subintervalsCount); } public double Calculate(Func<double, double> func, double min, double max) { return Calculate(DefaultRule, func, min, max, DefaultSubintervalsCount); } } 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; } } public static Complex GetSpectralDensity(double U, double anguarFrequency, double T) { NumericalIntegration integration = new NumericalIntegration(); if (anguarFrequency == 0)// Учитываем деление на 0 return new Complex(U * T, 0); return U * integration.Calculate(t => Math.Cos(anguarFrequency * t), 0, T) - Complex.ImaginaryOne * U * integration.Calculate(t => Math.Sin(anguarFrequency * t), 0, T); } public static double GetSpectralDensityOfAmplitude(Complex spectralDensity) { return Complex.Abs(spectralDensity); } public static double u1(double U, double anguarFrequency, double T)//U'(w) { NumericalIntegration integration = new NumericalIntegration(); return U * integration.Calculate(t => Math.Cos(anguarFrequency), 0, T); } public static double u2(double U, double anguarFrequency, double T)//U''(w) { NumericalIntegration integration = new NumericalIntegration(); return U * integration.Calculate(t => Math.Sin(anguarFrequency), 0, T); } public static Complex ValFurieTrans(double U, double anguarFrequency, double T)//Комплексное число U'(w) - U''(w) { return new Complex(u1(U, anguarFrequency, T), u2(U, anguarFrequency, T)); } public static double achx(double U, double anguarFrequency, double T)//АЧХ { return Math.Sqrt(Math.Pow(u1(U, anguarFrequency, T), 2) + Math.Pow(u2(U, anguarFrequency, T), 2)); } public static double fchx(double U, double anguarFrequency, double T)// ФЧХ { return Math.Atan(u2(U, anguarFrequency, T) / u1(U, anguarFrequency, T)); } public static double reverstrans(double U, double anguarFrequency, double T, int frc, int frc1)///Обратное преобразование Фурье // public static Complex reverstrans(double U, double anguarFrequency, double T,int frc,int frc1)///Обратное преобразование Фурье { NumericalIntegration integration = new NumericalIntegration(); return (1 / (2 * Math.PI)) * achx(U, anguarFrequency, T) * integration.Calculate(t => Math.Cos(fchx(U, anguarFrequency, T) + anguarFrequency * t), frc, frc1) + (Complex.ImaginaryOne / (2 * Math.PI)) * achx(U, anguarFrequency, T) * integration.Calculate(t => Math.Sin(fchx(U, anguarFrequency, T) + anguarFrequency * t), frc, frc1); } public string zedGraph_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { PointPair point = curve[iPt]; string result = string.Format("X: {0:F3}\nY: {1:F3}", point.X, point.Y); return result; } private void button5_Click(object sender, EventArgs e) { this.Close(); } private void button4_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); dataGridView1.Rows.Clear(); } private void button1_Click(object sender, EventArgs e) { int T = Convert.ToInt32(textBox1.Text); int U = Convert.ToInt32(textBox2.Text); double shag = Convert.ToDouble(textBox3.Text); int frc = Convert.ToInt32(textBox4.Text); int frc1 = Convert.ToInt32(textBox5.Text); int frequency, counter; List<Complex> values = new List<Complex>(); for (frequency = frc, counter = 1; frequency <= frc1; frequency++, counter++) { values.Add(reverstrans(U, frequency, T,frc,frc1)); } dataGridView1.DataSource = values; dataGridView1.Columns[0].DisplayIndex = 1; List<double> moduls = new List<double>(); for (frequency = frc, counter = 1; frequency <= frc1; frequency++, counter++) { moduls.Add(GetSpectralDensityOfAmplitude(GetSpectralDensity(U, frequency, T))); } foreach (double item in moduls) { listBox1.Items.Add(item.ToString()); } } } } An exception
Необработанное исключение типа "System.OutOfMemoryException" в mscorlib.dll
Occurs when calling the drawreverse method.
public void drawreverse(double U, double anguarFrequency, double T, double shag,int frc,int frc1) { GraphPane panel77 = zedGraphControl2.GraphPane; PointPairList list = new PointPairList(); double xmin = -100; double xmax = 100; List<Complex> values = new List<Complex>(); for (double fr = xmin; fr <= xmax; fr += shag) { double angularFrequency = 2 * Math.PI * fr; values.Add(reverstrans(U, anguarFrequency, T, frc, frc1)); values.ForEach(x1 =>list.Add(angularFrequency,x1.Real)); } zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); } Swears at the string
values.ForEach(x1 =>list.Add(angularFrequency,x1.Real)); In this line, I try to remove a real number from the received values of reverstrans. To begin with, I load all the obtained values into the List-values list. Therefore, using the above line, I want to remove the actual number from the list and add it as a coordinate to the list. Add Stack of Calls


reverstransfunctionreverstransn't compile. - VladD pmdrawgraphit possible to take out calculations from thedrawgraphmethod and transfer the ready data there? In this case, you can get rid of the graphic part. - VladD pm