Ejemplo n.º 1
0
        public string Resolve(double [] coeffs, int degree)
        {
            TextToReturn = "";
            Polynom polynom           = ReadPolynom(coeffs, degree);
            int     numberOfRoots     = polynom.GetDegree();
            DifferentialEvolution alg = new DifferentialEvolution();

            for (int i = 0; i < numberOfRoots; ++i)
            {
                alg.SetEquation(polynom);

                double[] result = alg.ExecuteDifferential();

                Console.WriteLine("Solutia {0} : {1} + i*{2}", i, Math.Round(result[0], 4), Math.Round(result[1], 4));
                TextToReturn += string.Format("Solutia {0} : {1} + i*{2}\r\n", i, Math.Round(result[0], 4), Math.Round(result[1], 4));
                if (i < numberOfRoots - 1)
                {
                    polynom = polynom.SimplifyEquation(
                        new Complex(Math.Round(result[0], 5), Math.Round(result[1], 5))
                        );
                }
            }

            return(TextToReturn);
        }