コード例 #1
0
 public void EvaluateTest()
 {
     PolynomialEq target = new PolynomialEq(4,2,1);
     double at = 3F; // TODO: Initialize to an appropriate value
     double expected = 43F; // TODO: Initialize to an appropriate value
     double actual = target.Evaluate(at);
     Assert.AreEqual(expected, actual);
 }
コード例 #2
0
        public void EvaluateAndEvaluateTheDerivativeTest()
        {
            PolynomialEq target = new PolynomialEq(4, 2, 1);
            double at = 3F; // TODO: Initialize to an appropriate value
            Tuple<double, double> expected = new Tuple<double, double>(43, 26);
            Tuple<double, double> actual = target.EvaluateAndEvaluateTheDerivative(at);

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #3
0
        static void getAllRoots()
        {
            //3x^2 + 6x + 0
            List<double> roots = new PolynomialEq(3, 6, 0).GetRoots();
            for(int i=0; i < roots.Count(); i++){
                Console.WriteLine("Root " + i.ToString() + ": " + roots[i].ToString());
            }
            Console.WriteLine();
                            //6x^2 + 7x + -3
            roots = new PolynomialEq(6, 7, -3).GetRoots();
            for (int i = 0; i < roots.Count(); i++) {
                Console.WriteLine("Root " + i.ToString() + ": " + roots[i].ToString());
            }
            Console.WriteLine();
                                //11x^2 -2x + -3
            roots = new PolynomialEq(11, -2, -3).GetRoots();
            for (int i = 0; i < roots.Count(); i++) {
                Console.WriteLine("Root " + i.ToString() + ": " + roots[i].ToString());
            }

            Console.ReadLine();
        }
コード例 #4
0
 static void vanDerWaals()
 {
     //Van Der Waals:
     double a = 2, R = 8.31, T = 320, P = 100, b = 1;
     var eq = new PolynomialEq(-a, R * T + P * b, P);
     var roots = eq.GetRoots();
     foreach (double d in roots) {
         Console.WriteLine("Root:" + d.ToString());
         Console.WriteLine("(error: " + eq.Evaluate(d).ToString() + ")");
     }
     Console.ReadLine();
 }