示例#1
0
 public void TestPolDeriv()
 {
     polD = pol1.Derivate();
     Assert.AreEqual("6x+2", polD.ToString());
     Assert.AreEqual(1, polD.Degree);
     polD.Derivate();
     Assert.AreEqual("6x+2", polD.ToString());
     polD = polD.Derivate();
     Assert.AreEqual("6", polD.ToString());
     polD = polD.Derivate();
     Assert.AreEqual("0", polD.ToString());
 }
示例#2
0
        //return the root of the derivate of degree 1
        public double FindRootsLine()
        {
            double result;

            if (degree == 1)
            {
                result = -coeffs[0] / coeffs[1];
            }
            else if (degree == 0)
            {
                throw new Exception("Polynome cannot be of degree 0");
            }
            else
            {
                Polynome polD = Derivate();
                while (polD.Degree > 1)
                {
                    polD = polD.Derivate();
                }
                result = -polD.Coeffs[0] / polD.Coeffs[1];
            }
            return(result);
        }