private void DrawChebyshevTable()
        {
            float[] xValues = new float[]
            {
                -3.2f, -2.1f, 0.4f, 0.7f, 2.0f, 2.5f, 2.777f
            };
            float[] yValues = new float[]
            {
                10.0f, -2.0f, 0, -7.0f, 7.0f, 0, 0
            };

            float a = xValues[0];
            float b = xValues[xValues.Length - 1];

            var coefs = ChebyshevApproximation.Approximate(xValues, yValues, 0);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 1);
            MnkK1Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 2);
            MnkK2Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 3);
            MnkK3Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 4);
            MnkK4Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 5);
            MnkK5Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(xValues, yValues, 6);
            MnkK6Plotter.ItemsSource = GeneratePoints(coefs, a, b);
        }
        private void DrawChebyshevFunc()
        {
            var coefs = ChebyshevApproximation.Approximate(a, b, 1, ApproximatedFunction);

            MnkK1Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 2, ApproximatedFunction);
            MnkK2Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 3, ApproximatedFunction);
            MnkK3Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 4, ApproximatedFunction);
            MnkK4Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 5, ApproximatedFunction);
            MnkK5Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 6, ApproximatedFunction);
            MnkK6Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 7, ApproximatedFunction);
            MnkK7Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 8, ApproximatedFunction);
            MnkK8Plotter.ItemsSource = GeneratePoints(coefs, a, b);

            coefs = ChebyshevApproximation.Approximate(a, b, 9, ApproximatedFunction);
            MnkK9Plotter.ItemsSource = GeneratePoints(coefs, a, b);
        }
        public void ApproximateTableValues()
        {
            float[] xValues = new float[]
            {
                -3.2f, -2.1f, 0.4f, 0.7f, 2.0f, 2.5f, 2.777f
            };
            float[] yValues = new float[]
            {
                10.0f, -2.0f, 0, -7.0f, 7.0f, 0, 0
            };
            var polynom = ChebyshevApproximation.Approximate(xValues, yValues, xValues.Length - 1);

            Assert.That(polynom.Length == xValues.Length);
        }
        public void Approximate()
        {
            float a       = -2.0f;
            float b       = 2.0f;
            float step    = 0.5f;
            int   rank    = ChebyshevApproximation.CalculateRank(a, b, step);
            var   polynom = ChebyshevApproximation.Approximate(a, b, rank, myFunc);

            List <float> results = new List <float>();
            var          xApprox = GenerateX(a, b, 0.0001f);

            for (float i = a; i <= b; i += 0.0001f)
            {
                float x = ChebyshevApproximation.Squish(i, a, b);
                results.Add(ChebyshevApproximation.Evaluate(polynom, x));
            }
            Assert.That(polynom.Length == rank + 1);
        }
        public void CompareTableAndFunc()
        {
            float a       = -2.0f;
            float b       = 2.0f;
            float step    = 0.5f;
            int   rank    = ChebyshevApproximation.CalculateRank(a, b, step);
            var   xValues = GenerateX(a, b, step);
            var   yValues = new float[rank];

            for (int i = 0; i < rank; i++)
            {
                yValues[i] = (float)myFunc(xValues[i]);
            }

            var expectedCoefficients = new Matrix(ChebyshevApproximation.Approximate(a, b, rank - 1, myFunc));

            var actualCoefficients = new Matrix(ChebyshevApproximation.Approximate(xValues, yValues, xValues.Length - 1));

            Assert.That(actualCoefficients.NearEquals(expectedCoefficients, (float)Math.PI + 0.2f), $"Expected: {expectedCoefficients.ToString()}, actual {actualCoefficients.ToString()}");
        }
        private void DemoTable_Chebyshev_Click(object sender, RoutedEventArgs e)
        {
            CleanDataSources();
            float[] xValues = new float[]
            {
                0, 3.3f, 6.6f, 9.9f
            };
            float[] yValues = new float[]
            {
                2.1f, 5.9f, 2.4f, 3.4f
            };


            var coefs = ChebyshevApproximation.Approximate(
                xValues,
                yValues,
                1
                );

            MnkK1Plotter.ItemsSource = GeneratePoints(coefs, xValues[0], xValues[xValues.Length - 1]);

            coefs = ChebyshevApproximation.Approximate(
                xValues,
                yValues,
                2
                );

            MnkK2Plotter.ItemsSource = GeneratePoints(coefs, xValues[0], xValues[xValues.Length - 1]);

            coefs = ChebyshevApproximation.Approximate(
                xValues,
                yValues,
                3
                );

            MnkK3Plotter.ItemsSource = GeneratePoints(coefs, xValues[0], xValues[xValues.Length - 1]);


            DrawBasePoints(xValues, yValues);
        }