예제 #1
0
    private static void chebyshev_even2_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHEBYSHEV_EVEN2_TEST tests CHEBYSHEV_EVEN2.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        Console.WriteLine("");
        Console.WriteLine("CHEBYSHEV_EVEN2_TEST:");
        Console.WriteLine("  CHEBYSHEV_EVEN2 computes the even Chebyshev coefficients");
        Console.WriteLine("  of a function F, using the zeros of Tn(x).");

        const int n = 6;

        double[] b2 = Chebyshev.chebyshev_even2(n, f);

        const int s = n / 2;

        typeMethods.r8vec_print(s + 1, b2, "  Computed Coefficients:");
    }
예제 #2
0
	private static void Main()
	{
		Point p = new Point2D(1, 2);
		IVisitor v = new Chebyshev();
		p.Accept(v);
		Console.WriteLine(p.Metric);
	}
예제 #3
0
        public void ZeroSizeListTest()
        {
            var m    = new Chebyshev();
            var list = new List <Utility>();
            var aVal = m.Calculate(list);

            Assert.That(aVal, Is.EqualTo(Zero).Within(Tolerance));
        }
예제 #4
0
    private static void Main()
    {
        Point    p = new Point2D(1, 2);
        IVisitor v = new Chebyshev();

        p.Accept(v);
        Console.WriteLine(p.Metric);
    }
예제 #5
0
    private static void mltply_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MLTPLY_TEST tests MLTPLY, which multiplies two Chebyshev series.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    24 September 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       i;
        const int nf  = 5;
        const int npl = 10;

        Console.WriteLine("");
        Console.WriteLine("MLTPLY_TEST");
        Console.WriteLine("  MLTPLY computes the product of two Chebyshev series.");
        Console.WriteLine("");
        Console.WriteLine("  Multiply series for SIN(X) and COS(X)");
        Console.WriteLine("  and compare with series for 1/2*SIN(2X).");

        double[] x = Chebyshev.cheby(nf, npl, functn);

        double[] x1 = new double[npl];
        double[] x2 = new double[npl];

        for (i = 0; i < npl; i++)
        {
            x1[i]          = x[i + 0 * npl];
            x2[i]          = x[i + 1 * npl];
            x[i + 2 * npl] = 0.5 * x[i + 2 * npl];
        }

        double[] x3 = ChebyshevSeries.mltply_new(x1, x2, npl);

        Console.WriteLine("");
        Console.WriteLine("          Sin(x)          Cos(x)       1/2*Sin(2x)         RESULT");
        Console.WriteLine("");

        for (i = 0; i < npl; i++)
        {
            Console.WriteLine("  " + x[i + 0 * npl].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + x[i + 1 * npl].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + x[i + 2 * npl].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + x3[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
예제 #6
0
        public void ZeroValuesTest()
        {
            var m    = new Chebyshev();
            var list = MeasureTestsHelper.RandomUtilityWeightList(_rnd.Next(1, MaxVecLen), 0.0f);

            float aVal = m.Calculate(list);
            float cVal = MeasureTestsHelper.CalculateChebyshevNorm(list);

            Assert.That(aVal, Is.EqualTo(Zero).Within(Tolerance));
            Assert.That(cVal, Is.EqualTo(Zero).Within(Tolerance));
        }
예제 #7
0
        public void CalculateTest()
        {
            var   m    = new Chebyshev();
            var   list = MeasureTestsHelper.RandomUtilityList(_rnd.Next(1, MaxVecLen));
            var   aVal = m.Calculate(list);
            float cVal = MeasureTestsHelper.CalculateChebyshevNorm(list);

            Assert.That(aVal, Is.EqualTo(cVal).Within(Tolerance));
            Assert.That(aVal <= One);
            Assert.That(aVal >= Zero);
        }
예제 #8
0
 private void FindNearestNeighbors(Attributes[] testAttributes, Attributes tuner, int k)
 {
     foreach (Attributes trainingInstance in testAttributes)
     {
         if (trainingInstance.xy != tuner.xy)
         {
             Calculator tCalc = new Calculator(tuner.xy, trainingInstance.xy);
             Euclidaen.Add(new KeyValuePair <float, Attributes>(tCalc.getEuclidaen, trainingInstance));
             Chebyshev.Add(new KeyValuePair <float, Attributes>(tCalc.getChebyshev, trainingInstance));
             Manhattan.Add(new KeyValuePair <float, Attributes>(tCalc.getManhattan, trainingInstance));
         }
     }
     Euclidaen = Euclidaen.OrderBy(o => o.Key).Take(k).ToList();
     Chebyshev = Chebyshev.OrderBy(o => o.Key).Take(k).ToList();
     Manhattan = Manhattan.OrderBy(o => o.Key).Take(k).ToList();
 }
예제 #9
0
    public static void cheby_t_poly_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHEBY_T_POLY_VALUES_TEST tests CHEBY_T_POLY_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 March 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx = 0;
        int    n  = 0;
        double x  = 0;

        Console.WriteLine("");
        Console.WriteLine("CHEBY_T_POLY_VALUES_TEST:");
        Console.WriteLine("  CHEBY_T_POLY_VALUES returns values of");
        Console.WriteLine("  the Chebyshev T polynomials.");
        Console.WriteLine("");
        Console.WriteLine("     N       X      T(N)(X)");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Chebyshev.cheby_t_poly_values(ref n_data, ref n, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }
예제 #10
0
    private static void cheby_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHEBY_TEST tests CHEBY, which computes Chebyshev series.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    24 September 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       i;
        const int nf  = 5;
        const int npl = 10;

        Console.WriteLine("");
        Console.WriteLine("CHEBY_TEST");
        Console.WriteLine("  CHEBY computes the Chebyshev series for several functions.");

        double[] x = Chebyshev.cheby(nf, npl, functn);

        Console.WriteLine("");
        Console.WriteLine("          Sin(x)          Cos(x)        Sin(2x)         Cos(2x)           X^5");
        Console.WriteLine("");

        for (i = 0; i < npl; i++)
        {
            string cout = "";
            int    j;
            for (j = 0; j < nf; j++)
            {
                cout += "  " + x[i + j * npl].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout);
        }
    }
예제 #11
0
    private static void chebyshev_even1_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHEBYSHEV_EVEN1_TEST tests CHEBYSHEV_EVEN1.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] a2_exact =
        {
            0.4477815660,
            -0.7056685603,
            0.0680357987,
            -0.0048097159
        }

        ;

        Console.WriteLine("");
        Console.WriteLine("CHEBYSHEV_EVEN1_TEST:");
        Console.WriteLine("  CHEBYSHEV_EVEN1 computes the even Chebyshev coefficients");
        Console.WriteLine("  of a function F, using the extreme points of Tn(x).");

        const int n = 6;

        double[] a2 = Chebyshev.chebyshev_even1(n, f);

        const int s = n / 2;

        typeMethods.r8vec2_print(s + 1, a2, a2_exact, "  Computed and Exact Coefficients:");
    }
예제 #12
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests CHEBYSHEV_COEFFICIENTS and CHEBYSHEV_INTERPOLANT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    14 September 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("CHEBYSHEV_TEST01");
        Console.WriteLine("  CHEBYSHEV_COEFFICIENTS computes the coefficients of the");
        Console.WriteLine("  Chebyshev interpolant.");
        Console.WriteLine("  CHEBYSHEV_INTERPOLANT evaluates the interpolant.");

        int    n = 5;
        double a = -1.0;
        double b = +1.0;

        double[] c = Chebyshev.chebyshev_coefficients(a, b, n, f1);

        double[] x = Chebyshev.chebyshev_zeros(n);
        for (i = 0; i < n; i++)
        {
            x[i] = 0.5 * (a + b) + x[i] * 0.5 * (b - a);
        }

        int m = n;

        double[] fc = Chebyshev.chebyshev_interpolant(a, b, n, c, m, x);

        Console.WriteLine("");
        Console.WriteLine("  F(X) is a trig function:");
        Console.WriteLine("");
        Console.WriteLine("          X               C(I)            F(X)           C(F)(X)");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + c[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + f1(x[i]).ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + fc[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Try a variant interval.
        //
        n = 5;
        a = 0.0;
        b = +3.0;

        c = Chebyshev.chebyshev_coefficients(a, b, n, f1);

        x = Chebyshev.chebyshev_zeros(n);
        for (i = 0; i < n; i++)
        {
            x[i] = 0.5 * (a + b) + x[i] * 0.5 * (b - a);
        }

        m  = n;
        fc = Chebyshev.chebyshev_interpolant(a, b, n, c, m, x);

        Console.WriteLine("");
        Console.WriteLine("  Consider the same F(X), but now over [0,3]:");
        Console.WriteLine("");
        Console.WriteLine("          X               C(I)            F(X)           C(F)(X)");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + c[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + f1(x[i]).ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + fc[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Try a higher order.
        //
        n = 10;
        a = -1.0;
        b = +1.0;

        c = Chebyshev.chebyshev_coefficients(a, b, n, f1);

        x = Chebyshev.chebyshev_zeros(n);
        for (i = 0; i < n; i++)
        {
            x[i] = 0.5 * (a + b) + x[i] * 0.5 * (b - a);
        }

        m  = n;
        fc = Chebyshev.chebyshev_interpolant(a, b, n, c, m, x);

        Console.WriteLine("");
        Console.WriteLine("  Consider the same F(X), but now with higher order:");
        Console.WriteLine("");
        Console.WriteLine("          X               C(I)            F(X)           C(F)(X)");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + c[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + f1(x[i]).ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + fc[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Try a polynomial.
        //
        n = 10;
        a = -1.0;
        b = +1.0;

        c = Chebyshev.chebyshev_coefficients(a, b, n, f3);

        x = Chebyshev.chebyshev_zeros(n);
        for (i = 0; i < n; i++)
        {
            x[i] = 0.5 * (a + b) + x[i] * 0.5 * (b - a);
        }

        m  = n;
        fc = Chebyshev.chebyshev_interpolant(a, b, n, c, m, x);

        Console.WriteLine("");
        Console.WriteLine("  F(X) is a degree 4 polynomial:");
        Console.WriteLine("");
        Console.WriteLine("          X               C(I)            F(X)           C(F)(X)");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + c[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + f3(x[i]).ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + fc[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        //
        //  Try a function with decaying behavior.
        //
        n = 10;
        a = -1.0;
        b = +1.0;

        c = Chebyshev.chebyshev_coefficients(a, b, n, f2);

        x = Chebyshev.chebyshev_zeros(n);
        for (i = 0; i < n; i++)
        {
            x[i] = 0.5 * (a + b) + x[i] * 0.5 * (b - a);
        }

        m  = n;
        fc = Chebyshev.chebyshev_interpolant(a, b, n, c, m, x);

        Console.WriteLine("");
        Console.WriteLine("  The polynomial approximation to F(X) decays:");
        Console.WriteLine("");
        Console.WriteLine("          X               C(I)            F(X)           C(F)(X)");
        Console.WriteLine("");
        for (i = 0; i < n; i++)
        {
            Console.WriteLine("  " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + c[i].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + f2(x[i]).ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + fc[i].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
예제 #13
0
    public static double[] cardan_poly(int n, double x, double s)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CARDAN_POLY evaluates the Cardan polynomials.
    //
    //  First terms:
    //
    //     N  C(N,S,X)
    //
    //     0  2
    //     1  X
    //     2  X^2  -  2 S
    //     3  X^3  -  3 S X
    //     4  X^4  -  4 S X^2 +  2 S^2
    //     5  X^5  -  5 S X^3 +  5 S^2 X
    //     6  X^6  -  6 S X^4 +  9 S^2 X^2 -  2 S^3
    //     7  X^7  -  7 S X^5 + 14 S^2 X^3 -  7 S^3 X
    //     8  X^8  -  8 S X^6 + 20 S^2 X^4 - 16 S^3 X^2 +  2 S^4
    //     9  X^9  -  9 S X^7 + 27 S^2 X^5 - 30 S^3 X^3 +  9 S^4 X
    //    10  X^10 - 10 S X^8 + 35 S^2 X^6 - 50 S^3 X^4 + 25 S^4 X^2 -  2 S^5
    //    11  X^11 - 11 S X^9 + 44 S^2 X^7 - 77 S^3 X^5 + 55 S^4 X^3 - 11 S^5 X
    //
    //  Recursion:
    //
    //    Writing the N-th polynomial in terms of its coefficients:
    //
    //      C(N,S,X) = sum ( 0 <= I <= N ) D(N,I) * S^(N-I)/2 * X^I
    //
    //    then
    //
    //    D(0,0) = 1
    //
    //    D(1,1) = 1
    //    D(1,0) = 0
    //
    //    D(N,N) = 1
    //    D(N,K) = D(N-1,K-1) - D(N-2,K)
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    28 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Reference:
    //
    //    Thomas Osler,
    //    Cardan Polynomials and the Reduction of Radicals,
    //    Mathematics Magazine,
    //    Volume 74, Number 1, February 2001, pages 26-32.
    //
    //  Parameters:
    //
    //    Input, int N, the highest polynomial to compute.
    //
    //    Input, double X, the point at which the polynomials are to be computed.
    //
    //    Input, double S, the value of the parameter, which must be positive.
    //
    //    Output, double CARDAN_POLY[N+1], the values of the Cardan polynomials at X.
    //
    {
        int i;

        double[] x2 = new double[1];

        double s2 = Math.Sqrt(s);

        x2[0] = 0.5 * x / s2;

        double[] v = Chebyshev.cheby_t_poly(1, n, x2);

        double fact = 1.0;

        for (i = 0; i <= n; i++)
        {
            v[i]  = 2.0 * fact * v[i];
            fact *= s2;
        }

        return(v);
    }
예제 #14
0
    private static void dfrnt_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    DFRNT_TEST tests DFRNT, which computes the Chebyshev series of a derivative.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    24 September 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       i;
        int       j;
        const int nf  = 5;
        const int npl = 10;

        Console.WriteLine("");
        Console.WriteLine("DFRNT_TEST");
        Console.WriteLine("  DFRNT computes the Chebyshev series for the derivative");
        Console.WriteLine("  of several functions.");

        double[] x  = Chebyshev.cheby(nf, npl, functn);
        double[] x2 = new double[npl];

        for (j = 0; j < nf; j++)
        {
            for (i = 0; i < npl; i++)
            {
                x2[i] = x[i + j * npl];
            }

            double[] x3 = ChebyshevSeries.dfrnt(x2, npl);
            for (i = 0; i < npl; i++)
            {
                x[i + j * npl] = x3[i];
            }
        }

        Console.WriteLine("");
        Console.WriteLine("  Chebyshev series for d/dx of:");
        Console.WriteLine("");
        Console.WriteLine("        Sin(x)      Cos(x)    Sin(2x)     Cos(2x)       X^5");
        Console.WriteLine("");

        for (i = 0; i < npl; i++)
        {
            string cout = "";
            for (j = 0; j < nf; j++)
            {
                cout += "  " + x[i + j * npl].ToString(CultureInfo.InvariantCulture).PadLeft(14);
            }

            Console.WriteLine(cout);
        }
    }
예제 #15
0
        public static BasisFunctionBase BasisFunctionSelector(BasisFunctionsEnum functionChoise)
        {
            //default
            BasisFunctionBase solver = null;

            switch (functionChoise)
            {
            case BasisFunctionsEnum.AsymmetricGaussian:
                solver = new AsymmetricGaussian();
                solver.Coefficients    = new double[4];
                solver.Coefficients[0] = .5;
                solver.Coefficients[1] = .5;
                solver.Coefficients[2] = .3;
                solver.Coefficients[3] = 1;
                break;

            case BasisFunctionsEnum.Linear:
                solver = new Linear();
                solver.Coefficients    = new double[2];
                solver.Coefficients[0] = 1;     // m
                solver.Coefficients[1] = 0;     // b
                break;

            case BasisFunctionsEnum.PolynomialQuadratic:
            {
                solver = new Quadratic();
                solver.Coefficients    = new double[3];
                solver.Coefficients[0] = 1;        //ax^2
                solver.Coefficients[1] = 1;        //bx
                solver.Coefficients[2] = 1;        //c
            }
            break;

            case BasisFunctionsEnum.PolynomialCubic:
            {
                solver = new Cubic();
                solver.Coefficients    = new double[7];
                solver.Coefficients[0] = 1;        //ax^3
                solver.Coefficients[1] = 1;        //bx^2
                solver.Coefficients[2] = 1;        //cx
                solver.Coefficients[3] = 1;        //d
                solver.Coefficients[4] = 1;        //d
                solver.Coefficients[5] = 1;        //d
                solver.Coefficients[6] = 1;        //d
            }
            break;

            case BasisFunctionsEnum.Lorentzian:
            {
                solver = new Lorentian();
                solver.Coefficients    = new double[3];
                solver.Coefficients[0] = 6;        //width
                solver.Coefficients[1] = 50;       //height
                solver.Coefficients[2] = -1;       //xoffset
            }
            break;

            case BasisFunctionsEnum.Gaussian:
            {
                solver = new Gaussian();
                solver.Coefficients    = new double[3];
                solver.Coefficients[0] = 6;        //sigma
                solver.Coefficients[1] = 50;       //height
                solver.Coefficients[2] = -1;       //xoffset
            }
            break;

            case BasisFunctionsEnum.Chebyshev:
            {
                solver = new Chebyshev();
                solver.Coefficients    = new double[6];
                solver.Coefficients[0] = 0;        //?
                solver.Coefficients[1] = 1;        //?
                solver.Coefficients[2] = 1;        //?
                solver.Coefficients[3] = 0;        //?
                solver.Coefficients[4] = 0;        //?
                solver.Coefficients[5] = 0;        //?
            }
            break;

            case BasisFunctionsEnum.Orbitrap:
            {
                solver = new OrbitrapFunction();
                solver.Coefficients    = new double[3];
                solver.Coefficients[0] = 1;        //?
                solver.Coefficients[1] = 1;        //?
                solver.Coefficients[2] = 1;        //?
                //quadSolver.Coefficients[3] = 1;//?
                //quadSolver.Coefficients[4] = 1;//?
                //quadSolver.Coefficients[4] = 1;//?
            }
            break;

            case BasisFunctionsEnum.Hanning:
            {
                solver = new Hanning();
                solver.Coefficients    = new double[3];
                solver.Coefficients[0] = 1;        //?
                solver.Coefficients[1] = 1;        //?
                solver.Coefficients[2] = 1;        //?
            }
            break;
            }
            return(solver);
        }
예제 #16
0
        public void ConstructorTest()
        {
            var m = new Chebyshev();

            Assert.IsNotNull(m);
        }
예제 #17
0
    private static void edcheb_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    EDCHEB_TEST tests EDCHEB, which evaluates the derivative of a Chebyshev series.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    24 September 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int       j;
        const int nf  = 5;
        const int npl = 10;

        const int nx = 6;

        Console.WriteLine("");
        Console.WriteLine("EDCHEB_TEST");
        Console.WriteLine("  EDCHEB evaluates the derivative of a Chebyshev series.");

        double[] x  = Chebyshev.cheby(nf, npl, functn);
        double[] x2 = new double[npl];

        for (j = 0; j < nf; j++)
        {
            int i;
            for (i = 0; i < npl; i++)
            {
                x2[i] = x[i + j * npl];
            }

            Console.WriteLine("");
            switch (j)
            {
            case 0:
                Console.WriteLine("  Sin(x)");
                break;

            case 1:
                Console.WriteLine("  Cos(x)");
                break;

            case 2:
                Console.WriteLine("  Sin(2x)");
                break;

            case 3:
                Console.WriteLine("  Cos(2x)");
                break;

            case 4:
                Console.WriteLine("  x^5");
                break;
            }

            Console.WriteLine("");

            int k;
            for (k = 0; k < nx; k++)
            {
                double xval = 2.0 * k / (nx - 1) - 1.0;

                double[] fxj = functn_d(xval);

                double fval = ChebyshevSeries.edcheb(xval, x2, npl);

                Console.WriteLine("  " + xval.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                                  + "  " + fxj[j].ToString(CultureInfo.InvariantCulture).PadLeft(14)
                                  + "  " + fval.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
            }
        }
    }