Example #1
0
        public virtual double[] Roots()
        {
            var roots = new List <double>();
            var p     = new Polynomial(1);

            while (true)
            {
                var root = NonlinearEquations.NewtonMethod(new Quotient(this, p), 0);
                if (root == null)
                {
                    break;
                }
                roots.Add((double)root);
                p *= new Polynomial(-(double)root, 1);
            }
            roots.Sort();
            return(roots.ToArray());
        }
Example #2
0
 public static double BisectionSqrt(double n, int precision) => NonlinearEquations.Bisection(n >= 1 ? 1 : 0, n >= 1 ? n : 1, m => m * m - n, precision);
Example #3
0
 public static double Bisection(double n, int w, int precision) => NonlinearEquations.Bisection(n >= 1 ? 1 : 0, n >= 1 ? n : 1, m => System.Math.Pow(m, w) - n, precision);